Package org.tinspin.index.critbit
Class CritBit<V>
- java.lang.Object
-
- org.tinspin.index.critbit.CritBit<V>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCritBit.CheckEmptyWithMaskstatic classCritBit.Entry<V>static classCritBit.FullIterator<V>static classCritBit.QueryIterator<V>static classCritBit.QueryIteratorKD<V>static classCritBit.QueryIteratorWithMask<V>
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheckTree()booleancontains(long[] key)Check whether a given key exists in the tree.booleancontainsKD(long[] key)Check whether a given key exists in the tree.static <V> CritBit1D<V>create1D(int width)Create a 1D crit-bit tree with arbitrary key length.static <V> CritBitKD<V>createKD(int width, int dim)Create a kD crit-bit tree with maximum 64bit key length.Vget(long[] key)Get the value for a given key.VgetKD(long[] key)Get the value for a given key.CritBit.FullIterator<V>iterator()Create an iterator over all values, keys or entries.voidprintTree()Vput(long[] key, V val)Add a key value pair to the tree or replace the value if the key already exists.VputKD(long[] key, V val)Add a key value pair to the tree or replace the value if the key already exists.CritBit.QueryIterator<V>query(long[] min, long[] max)CritBit.QueryIteratorKD<V>queryKD(long[] min, long[] max)Performs a k-dimensional query.protected static <T> voidreadInfix(org.tinspin.index.critbit.CritBit.Node<T> n, long[] currentPrefix)Vremove(long[] key)Remove a key and its valueVremoveKD(long[] key)Remove a key and its valueintsize()Get the size of the tree.StringtoString()
-
-
-
Method Detail
-
create1D
public static <V> CritBit1D<V> create1D(int width)
Create a 1D crit-bit tree with arbitrary key length.- Type Parameters:
V- value type- Parameters:
width- The number of bits per value- Returns:
- a 1D crit-bit tree
-
createKD
public static <V> CritBitKD<V> createKD(int width, int dim)
Create a kD crit-bit tree with maximum 64bit key length.- Type Parameters:
V- value type- Parameters:
width- The number of bits per valuedim- The number of dimensions- Returns:
- k-dimensional tree
-
put
public V put(long[] key, V val)
Add a key value pair to the tree or replace the value if the key already exists.- Specified by:
putin interfaceCritBit1D<V>- Parameters:
key- keyval- value- Returns:
- The previous value or
nullif there was no previous value - See Also:
put(long[], Object)
-
printTree
public void printTree()
-
checkTree
public boolean checkTree()
-
readInfix
protected static <T> void readInfix(org.tinspin.index.critbit.CritBit.Node<T> n, long[] currentPrefix)- Type Parameters:
T- value type- Parameters:
n- nodecurrentPrefix- prefix
-
size
public int size()
Get the size of the tree.
-
contains
public boolean contains(long[] key)
Check whether a given key exists in the tree.- Specified by:
containsin interfaceCritBit1D<V>- Parameters:
key- key- Returns:
trueif the key exists otherwisefalse- See Also:
contains(long[])
-
get
public V get(long[] key)
Get the value for a given key.- Specified by:
getin interfaceCritBit1D<V>- Parameters:
key- key- Returns:
- the values associated with
keyornullif the key does not exist. - See Also:
get(long[])
-
remove
public V remove(long[] key)
Remove a key and its value- Specified by:
removein interfaceCritBit1D<V>- Parameters:
key- key- Returns:
- The value of the key of
nullif the value was not found. - See Also:
remove(long[])
-
iterator
public CritBit.FullIterator<V> iterator()
Create an iterator over all values, keys or entries.- Specified by:
iteratorin interfaceCritBit1D<V>- Returns:
- the iterator
- See Also:
iterator()
-
query
public CritBit.QueryIterator<V> query(long[] min, long[] max)
- Specified by:
queryin interfaceCritBit1D<V>- Parameters:
min- Lower left corner of the query windowmax- Upper right corner of the query window- Returns:
- Iterator over query result
- See Also:
query(long[], long[])
-
putKD
public V putKD(long[] key, V val)
Add a key value pair to the tree or replace the value if the key already exists.- Specified by:
putKDin interfaceCritBitKD<V>- Parameters:
key- keyval- value- Returns:
- The previous value or
nullif there was no previous value - See Also:
putKD(long[], Object)
-
containsKD
public boolean containsKD(long[] key)
Check whether a given key exists in the tree.- Specified by:
containsKDin interfaceCritBitKD<V>- Parameters:
key- key- Returns:
trueif the key exists otherwisefalse- See Also:
containsKD(long[])
-
getKD
public V getKD(long[] key)
Get the value for a given key.- Specified by:
getKDin interfaceCritBitKD<V>- Parameters:
key- key- Returns:
- the values associated with
keyornullif the key does not exist. - See Also:
getKD(long[])
-
removeKD
public V removeKD(long[] key)
Remove a key and its value- Specified by:
removeKDin interfaceCritBitKD<V>- Parameters:
key- key- Returns:
- The value of the key of
nullif the value was not found. - See Also:
removeKD(long[])
-
queryKD
public CritBit.QueryIteratorKD<V> queryKD(long[] min, long[] max)
Performs a k-dimensional query.- Specified by:
queryKDin interfaceCritBitKD<V>- Parameters:
min- minimum keymax- maximum key- Returns:
- Result iterator
- See Also:
queryKD(long[], long[])
-
-