Package ghidra.util.datastruct
Class BitTree
- java.lang.Object
- 
- ghidra.util.datastruct.BitTree
 
- 
- All Implemented Interfaces:
- ShortKeySet,- java.io.Serializable
 
 public class BitTree extends java.lang.Object implements ShortKeySet, java.io.Serializable The BitTree class maintains a set of ordered keys between the values of 0 and N. It can quickly (O(log(n))) add keys, remove keys, find the next key greater than some value , and find the prev key less than some value. It can determine if a key is in the set in O(1) time. This implementation has been limited to short keys so that it can implement the ShortKeySet interface.- See Also:
- Serialized Form
 
- 
- 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsKey(short key)Determines if a given key is in the set.shortgetFirst()Returns the first (lowest) key in the set.shortgetLast()Returns the last (highest) key in the set.shortgetNext(short key)finds the next key that is in the set that is greater than the given key.shortgetPrevious(short key)Finds the next key that is in the set that is less than the given key.booleanisEmpty()Checks if the set is empty.voidput(short key)Adds a key to the set.booleanremove(short key)Removes the key from the set.voidremoveAll()Removes all keys from the set.intsize()Returns the number of keys currently in the set.
 
- 
- 
- 
Constructor Detail- 
BitTreepublic BitTree(short maxKey) The BitTree constructor takes the maximum key value. The legal keys for this set range from 0 to maxKey.- Parameters:
- maxKey- the maximum key that will ever be put into this BitTree.
 
 - 
BitTreepublic BitTree(short maxKey, boolean isFull)The BitTree constructor takes the maximum key value. The legal keys for this set range from 0 to maxKey.- Parameters:
- maxKey- the maximum key value.
- isFull- if true, then the set is initilized to contain all legal keys.
 
 
- 
 - 
Method Detail- 
removeAllpublic void removeAll() Removes all keys from the set.- Specified by:
- removeAllin interface- ShortKeySet
 
 - 
sizepublic int size() Returns the number of keys currently in the set.- Specified by:
- sizein interface- ShortKeySet
 
 - 
putpublic void put(short key) Adds a key to the set.- Specified by:
- putin interface- ShortKeySet
- Parameters:
- key- to be added.
- Throws:
- java.lang.IndexOutOfBoundsException- if the given key is not in the range [0, size-1].
 
 - 
removepublic boolean remove(short key) Removes the key from the set.- Specified by:
- removein interface- ShortKeySet
- Parameters:
- key- The key to remove.
- Throws:
- java.lang.IndexOutOfBoundsException- if the given key is not in the range [0, size-1].
 
 - 
containsKeypublic boolean containsKey(short key) Determines if a given key is in the set.- Specified by:
- containsKeyin interface- ShortKeySet
- Parameters:
- key- the key to check if it is in this set.
- Returns:
- true if the key is in the set.
 
 - 
getNextpublic short getNext(short key) finds the next key that is in the set that is greater than the given key.- Specified by:
- getNextin interface- ShortKeySet
- Parameters:
- key- from which to search forward.
- Returns:
- the next key greater than the given key or -1 if there is no key greater than the given key.
- Throws:
- java.lang.IndexOutOfBoundsException- if the given key is not in the range [0, size-1].
 
 - 
getPreviouspublic short getPrevious(short key) Finds the next key that is in the set that is less than the given key.- Specified by:
- getPreviousin interface- ShortKeySet
- Parameters:
- key- the key to search before.
- Returns:
- the next key less than the given key or -1 if there is no key less than the given key.
- Throws:
- java.lang.IndexOutOfBoundsException- if the given key is not in the range [0, size-1].
 
 - 
isEmptypublic boolean isEmpty() Checks if the set is empty.- Specified by:
- isEmptyin interface- ShortKeySet
- Returns:
- true if the set is empty.
 
 - 
getFirstpublic short getFirst() Returns the first (lowest) key in the set.- Specified by:
- getFirstin interface- ShortKeySet
 
 - 
getLastpublic short getLast() Returns the last (highest) key in the set.- Specified by:
- getLastin interface- ShortKeySet
 
 
- 
 
-