E
- The type of elements this set stores. It must implement the Comparable
interface or a Comparator
has to be provided at construction time.public class LLRBTree<E> extends java.util.AbstractSet<E> implements HGSortedSet<E>, java.lang.Cloneable, java.io.Serializable
Implements a set of elements as a left-leaning red-black tree. The node doesn't contain a pointer to a value, nor does it contains a pointer to the parent which should make it more memory efficient than most implementations (e.g. the standard java.util.TreeMap). However, tree mutations are implemented recursively, which is not optimal and could be removed in the future. Unfortunately, Java uses 4 bytes to store a boolean so we don't gain as much in space compactness as we could theoretically, but it's still an improvement.
Constructor and Description |
---|
LLRBTree() |
LLRBTree(java.util.Comparator<E> comparator) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(E key) |
boolean |
check() |
void |
clear() |
java.lang.Object |
clone() |
java.util.Comparator<E> |
comparator() |
boolean |
contains(java.lang.Object key) |
int |
depth() |
E |
first() |
HGRandomAccessResult<E> |
getSearchResult() |
java.util.SortedSet<E> |
headSet(E toElement) |
boolean |
is234() |
boolean |
isBalanced() |
boolean |
isBalanced(org.hypergraphdb.util.LLRBTree.Node<E> r) |
boolean |
isBST() |
boolean |
isEmtpy() |
java.util.Iterator<E> |
iterator() |
E |
last() |
boolean |
remove(java.lang.Object key) |
void |
removeMax() |
void |
removeMin() |
int |
size() |
java.util.SortedSet<E> |
subSet(E fromElement,
E toElement) |
java.util.SortedSet<E> |
tailSet(E fromElement) |
addAll, containsAll, isEmpty, retainAll, toArray, toArray, toString
public LLRBTree()
public LLRBTree(java.util.Comparator<E> comparator)
public void removeMax()
public void removeMin()
public int size()
public boolean isEmtpy()
public java.util.Comparator<E> comparator()
comparator
in interface java.util.SortedSet<E>
public void clear()
public boolean contains(java.lang.Object key)
public boolean add(E key)
public boolean remove(java.lang.Object key)
public java.util.SortedSet<E> headSet(E toElement)
headSet
in interface java.util.SortedSet<E>
public java.util.SortedSet<E> subSet(E fromElement, E toElement)
subSet
in interface java.util.SortedSet<E>
public java.util.SortedSet<E> tailSet(E fromElement)
tailSet
in interface java.util.SortedSet<E>
public java.util.Iterator<E> iterator()
public HGRandomAccessResult<E> getSearchResult()
getSearchResult
in interface HGSortedSet<E>
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
public int depth()
public boolean check()
public boolean isBST()
public boolean is234()
public boolean isBalanced()
public boolean isBalanced(org.hypergraphdb.util.LLRBTree.Node<E> r)