Class IntRedBlackTree
- java.lang.Object
-
- org.apache.uima.internal.util.rb_trees.IntRedBlackTree
-
public class IntRedBlackTree extends java.lang.Objectmap<int, int%gt; uses separate objects (IntRBTNode) as nodes See theRedBlackTreeclass. This is a specialized instance with ints as elements.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIntRedBlackTree.IntRBTIterator
-
Field Summary
Fields Modifier and Type Field Description (package private) IntRBTNoderoot(package private) intsize
-
Constructor Summary
Constructors Constructor Description IntRedBlackTree()Default constructor, does nothing.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontainsKey(int key)booleancontainsValue(int o)IntRedBlackTreecopy()intget(int key)intgetFirst()private IntRBTNodegetFirstNode()booleanisEmpty()IntRedBlackTree.IntRBTIteratoriterator()int[]keySet()voidprintKeys()Debugging aid.booleanput(int key, int el)Insert an object with a given key into the tree.private booleanput(IntRBTNode node)Insert a IntRBTNode into the tree.intremove(int key)Delete the node with the given key from the tree, if it exists.intsize()int[]toArray(int offset)Provides an array representation of the IntRedBlackTree.
-
-
-
Field Detail
-
root
IntRBTNode root
-
size
int size
-
-
Method Detail
-
size
public final int size()
-
clear
public final void clear()
-
containsKey
public final boolean containsKey(int key)
-
containsValue
public final boolean containsValue(int o)
-
put
public final boolean put(int key, int el)Insert an object with a given key into the tree.- Parameters:
key- The key under which the int is to be inserted.el- The int to be inserted.- Returns:
true, if the key was not in the tree;false, if an element with that key was already in the tree. The old element is overwritten with the new one.
-
remove
public final int remove(int key) throws java.util.NoSuchElementExceptionDelete the node with the given key from the tree, if it exists.- Parameters:
key- The key to be deleted.- Returns:
- -
- Throws:
java.util.NoSuchElementException
-
get
public final int get(int key) throws java.util.NoSuchElementException- Throws:
java.util.NoSuchElementException
-
isEmpty
public final boolean isEmpty()
-
keySet
public final int[] keySet()
-
put
private final boolean put(IntRBTNode node)
Insert a IntRBTNode into the tree. Only used internally.
-
getFirst
public final int getFirst()
-
getFirstNode
private final IntRBTNode getFirstNode()
-
iterator
public IntRedBlackTree.IntRBTIterator iterator()
-
printKeys
public void printKeys()
Debugging aid.
-
toArray
public int[] toArray(int offset)
Provides an array representation of the IntRedBlackTree. SeeIntRBTArrayfor the memory layout of the array. Note that the red-black information is lost in the translation. The resulting array is only meant to be read, not grown. The array is meant as input to construct anIntRBTArrayobject.- Parameters:
offset- An offset for internal addressing. Ifoffset > 0, the addresses generated for right daughters in two-daughter nodes are shifted to the right. This is useful if the resulting array will be copied to a certainoffsetposition in a different array.- Returns:
- The resulting array representation.
-
copy
public IntRedBlackTree copy()
-
-