Package com.db4o.foundation
Class Tree<T>
- java.lang.Object
-
- com.db4o.foundation.Tree<T>
-
- All Implemented Interfaces:
DeepClone,ShallowClone,Visitable<T>
- Direct Known Subclasses:
QPending,TreeInt,TreeObject
public abstract class Tree<T> extends java.lang.Object implements ShallowClone, DeepClone, Visitable<T>
-
-
Field Summary
Fields Modifier and Type Field Description Tree<T>_precedingint_sizeTree<T>_subsequent
-
Constructor Summary
Constructors Constructor Description Tree()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaccept(Visitor4<T> visitor)<V extends Tree<T>>
Vadd(V newNode)<V extends Tree<T>>
Vadd(V newNode, int cmp)On adding a node to a tree, if it already exists, and if Tree#duplicates() returns false, #isDuplicateOf() will be called.static <T,V extends Tree<T>>
Vadd(V oldTree, V newTree)TreeaddedOrExisting()On adding a node to a tree, if it already exists, and if Tree#duplicates() returns false, #onAttemptToAddDuplicate() will be called and the existing node will be stored in this._preceding.Treebalance()TreebalanceCheckNulls()voidcalculateSize()abstract intcompare(Tree a_to)returns 0, if keys are equal uses this - other returns positive if this is greater than a_to returns negative if this is smaller than a_tostatic TreedeepClone(Tree a_tree, java.lang.Object a_param)java.lang.ObjectdeepClone(java.lang.Object a_param)The parameter allows passing one new object so parent references can be corrected on children.static intdepth(Tree tree)booleanduplicates()Treefilter(Predicate4 a_filter)Tree<T>find(Tree<T> template)static <T> Tree<T>find(Tree<T> inTree, Tree<T> template)static TreefindGreaterOrEqual(Tree a_in, Tree a_finder)static TreefindSmaller(Tree a_in, Tree a_node)Tree<T>first()abstract Tkey()Treelast()static Treelast(Tree tree)intnodes()TreeonAttemptToAddDuplicate(Tree oldNode)intownSize()Treeremove()voidremoveChildren()TreeremoveFirst()static TreeremoveLike(Tree from, Tree a_find)<V extends Tree<T>>
VremoveLike(V a_find)TreeremoveNode(Tree a_tree)java.lang.Objectroot()TreerotateLeft()TreerotateRight()voidsetSizeOwn()voidsetSizeOwnPlus(Tree tree)voidsetSizeOwnPlus(Tree tree1, Tree tree2)voidsetSizeOwnPreceding()voidsetSizeOwnPrecedingSubsequent()voidsetSizeOwnSubsequent()java.lang.ObjectshallowClone()protected TreeshallowCloneInternal(Tree tree)intsize()static intsize(Tree a_tree)static voidtraverse(Tree tree, Tree startingNode, CancellableVisitor4 visitor)Traverses a tree with a starting point node.static voidtraverse(Tree tree, Visitor4 visitor)<V extends Tree<T>>
voidtraverse(Visitor4<V> visitor)voidtraverseFromLeaves(Visitor4 a_visitor)booleanwasAddedToTree()
-
-
-
Method Detail
-
add
public static final <T,V extends Tree<T>> V add(V oldTree, V newTree)
-
add
public <V extends Tree<T>> V add(V newNode, int cmp)
On adding a node to a tree, if it already exists, and if Tree#duplicates() returns false, #isDuplicateOf() will be called. The added node can then be asked for the node that prevails in the tree using #duplicateOrThis(). This mechanism allows doing find() and add() in one run.
-
addedOrExisting
public Tree addedOrExisting()
On adding a node to a tree, if it already exists, and if Tree#duplicates() returns false, #onAttemptToAddDuplicate() will be called and the existing node will be stored in this._preceding. This node node can then be asked for the node that prevails in the tree on adding, using the #addedOrExisting() method. This mechanism allows doing find() and add() in one run.
-
wasAddedToTree
public boolean wasAddedToTree()
-
balance
public final Tree balance()
-
balanceCheckNulls
public Tree balanceCheckNulls()
-
calculateSize
public void calculateSize()
-
compare
public abstract int compare(Tree a_to)
returns 0, if keys are equal uses this - other returns positive if this is greater than a_to returns negative if this is smaller than a_to
-
deepClone
public java.lang.Object deepClone(java.lang.Object a_param)
Description copied from interface:DeepCloneThe parameter allows passing one new object so parent references can be corrected on children.
-
duplicates
public boolean duplicates()
-
filter
public final Tree filter(Predicate4 a_filter)
-
last
public final Tree last()
-
nodes
public int nodes()
- Returns:
- the number of nodes in this tree for balancing
-
ownSize
public int ownSize()
-
remove
public Tree remove()
-
removeChildren
public void removeChildren()
-
removeFirst
public Tree removeFirst()
-
rotateLeft
public final Tree rotateLeft()
-
rotateRight
public final Tree rotateRight()
-
setSizeOwn
public final void setSizeOwn()
-
setSizeOwnPrecedingSubsequent
public final void setSizeOwnPrecedingSubsequent()
-
setSizeOwnPreceding
public final void setSizeOwnPreceding()
-
setSizeOwnSubsequent
public final void setSizeOwnSubsequent()
-
setSizeOwnPlus
public final void setSizeOwnPlus(Tree tree)
-
size
public static int size(Tree a_tree)
-
size
public int size()
- Returns:
- the number of objects represented.
-
traverse
public static void traverse(Tree tree, Tree startingNode, CancellableVisitor4 visitor)
Traverses a tree with a starting point node. If there is no exact match for the starting node, the next higher will be taken.
-
traverseFromLeaves
public final void traverseFromLeaves(Visitor4 a_visitor)
-
shallowClone
public java.lang.Object shallowClone()
- Specified by:
shallowClonein interfaceShallowClone
-
key
public abstract T key()
-
root
public java.lang.Object root()
-
depth
public static int depth(Tree tree)
-
-