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 AbstractSet<E> implements HGSortedSet<E>, Cloneable, 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(Comparator<E> comparator) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(E key) |
boolean |
check() |
void |
clear() |
Object |
clone() |
Comparator<E> |
comparator() |
boolean |
contains(Object key) |
int |
depth() |
E |
first() |
HGRandomAccessResult<E> |
getSearchResult() |
SortedSet<E> |
headSet(E toElement) |
boolean |
is234() |
boolean |
isBalanced() |
boolean |
isBalanced(org.hypergraphdb.util.LLRBTree.Node<E> r) |
boolean |
isBST() |
boolean |
isEmtpy() |
Iterator<E> |
iterator() |
E |
last() |
boolean |
remove(Object key) |
void |
removeMax() |
void |
removeMin() |
int |
size() |
SortedSet<E> |
subSet(E fromElement,
E toElement) |
SortedSet<E> |
tailSet(E fromElement) |
equals, hashCode, removeAll
addAll, containsAll, isEmpty, retainAll, toArray, toArray, toString
public LLRBTree()
public LLRBTree(Comparator<E> comparator)
public void removeMax()
public void removeMin()
public int size()
size
in interface Collection<E>
size
in interface Set<E>
size
in class AbstractCollection<E>
public boolean isEmtpy()
public Comparator<E> comparator()
comparator
in interface SortedSet<E>
public void clear()
clear
in interface Collection<E>
clear
in interface Set<E>
clear
in class AbstractCollection<E>
public boolean contains(Object key)
contains
in interface Collection<E>
contains
in interface Set<E>
contains
in class AbstractCollection<E>
public boolean add(E key)
add
in interface Collection<E>
add
in interface Set<E>
add
in class AbstractCollection<E>
public boolean remove(Object key)
remove
in interface Collection<E>
remove
in interface Set<E>
remove
in class AbstractCollection<E>
public HGRandomAccessResult<E> getSearchResult()
getSearchResult
in interface HGSortedSet<E>
public Object clone() throws CloneNotSupportedException
clone
in class Object
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)
Copyright © 2015. All rights reserved.