scala.collection.immutable
class Tree

[source: `scala/collection/immutable/Tree.scala`]

@serializable
`abstract` `class` Tree[A, B](`implicit` view$0 : (A) => Ordered[A])
  `extends` AnyRef

  General Balanced Trees - highly efficient functional dictionaries.

  An efficient implementation of Prof. Arne Andersson's General Balanced Trees. These have no storage overhead compared to plain unbalanced binary trees, and their performance is in general better than AVL trees.

  This implementation does not balance the trees after deletions. Since deletions don't increase the height of a tree, this should be OK in most applications. A balance method is provided for those cases where rebalancing is needed.

  The tree consists of entries conatining a key with an order.

  When instanciating the tree an order for the keys has to be supplied.

Author
  Erik Stenman, Michel Schinz
Version
  1.1, 2005-01-20

Type Summary
`protected abstract type` | This <: Tree[A, B] The type returned when creating a new tree. This type should be defined by concrete implementations e.g.
        class C[T](...) extends Tree[A,B](...) {
          type This = C[T];
`protected type` | aNode The type of nodes that the tree is build from.

Method Summary
`protected abstract def` | New (sz : Int, t : GBTree) : This This abstract method should be defined by a concrete implementation `C[T]` as something like:
          override def New(sz: Int, t: aNode): This {
            new C[T](order) {
              override def size = sz
              override protected def tree: aNode = t
          }
The concrete implementation should also override the def of This `override type This = C[T];`
`protected def` | add (key : A, entry : B) : This A new tree with the entry added is returned, assuming that key is not in the tree.
`def` | balance : This Create a new balanced tree from the tree. Might be useful to call after many deletions, since deletion does not rebalance the tree.
`protected def` | deleteAny (key : A) : This Removes the key from the tree.
`protected def` | entries : Iterator[B] Gives you an iterator over all elements in the tree. The iterator structure corresponds to the call stack of an in-order traversal. Note: The iterator itself has a state, i.e., it is not functional.
`protected def` | findValue (key : A) : Option[B] Check if this map maps `key` to a value and return the value if it exists.
`protected abstract def` | getThis : This
`def` | size : Int The size of the tree, returns 0 (zero) if the tree is empty.
`protected def` | tree : GBTree The nodes in the tree.
`protected def` | updateOrAdd (key : A, entry : B) : This A new tree with the entry added is returned, if key is not in the tree, otherwise the key is updated with the new entry.

Methods inherited from AnyRef
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized

Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf