public class IntRedBlackTree extends Object
RedBlackTree
class. This is a
specialized instance with ints as elements.Modifier and Type | Class and Description |
---|---|
static class |
IntRedBlackTree.IntRBTIterator |
Constructor and Description |
---|
IntRedBlackTree()
Default constructor, does nothing.
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(int key) |
boolean |
containsValue(int o) |
IntRedBlackTree |
copy() |
int |
get(int key) |
int |
getFirst() |
boolean |
isEmpty() |
IntRedBlackTree.IntRBTIterator |
iterator() |
int[] |
keySet() |
void |
printKeys()
Debugging aid.
|
boolean |
put(int key,
int el)
Insert an object with a given key into the tree.
|
int |
remove(int key)
Delete the node with the given key from the tree, if it exists.
|
int |
size() |
int[] |
toArray(int offset)
Provides an array representation of the IntRedBlackTree.
|
public final int size()
public final void clear()
public final boolean containsKey(int key)
public final boolean containsValue(int o)
public final boolean put(int key, int el)
key
- The key under which the int is to be inserted.el
- The int to be inserted.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.public final int remove(int key) throws NoSuchElementException
key
- The key to be deleted.NoSuchElementException
public final int get(int key) throws NoSuchElementException
NoSuchElementException
public final boolean isEmpty()
public final int[] keySet()
public final int getFirst()
public IntRedBlackTree.IntRBTIterator iterator()
public void printKeys()
public int[] toArray(int offset)
IntRBTArray
for 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 an
IntRBTArray
object.offset
- An offset for internal addressing. If offset > 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 certain offset
position in a different array.public IntRedBlackTree copy()
Copyright © 2014. All rights reserved.