Package ghidra.util.datastruct
Class RedBlackKeySet
- java.lang.Object
-
- ghidra.util.datastruct.RedBlackKeySet
-
- All Implemented Interfaces:
ShortKeySet,java.io.Serializable
public class RedBlackKeySet extends java.lang.Object implements ShortKeySet, java.io.Serializable
A RedBlack Tree implementation of the ShortKeySet interface.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static intNODESIZEthe number of bytes in a RedBlackKeySet node
-
Constructor Summary
Constructors Constructor Description RedBlackKeySet(short n)Creates a new RedBlackKeySet that can store keys between 0 and n.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsKey(short key)Returns true if the key is in the set.shortgetFirst()Returns the first key in this set.shortgetLast()Returns the last key in this set.shortgetNext(short key)Returns the smallest key in the set that is greater than the given key.shortgetPrevious(short key)Returns the largest key in the set that is less than the given key.booleanisEmpty()Test if the set is empty.voidput(short key)Adds the given key to the set.booleanremove(short key)Removes the given key from the set.voidremoveAll()Removes all keys from the set.intsize()Returns the number keys in this set.
-
-
-
Field Detail
-
NODESIZE
public static final int NODESIZE
the number of bytes in a RedBlackKeySet node- See Also:
- Constant Field Values
-
-
Method Detail
-
size
public int size()
Returns the number keys in this set.- Specified by:
sizein interfaceShortKeySet
-
containsKey
public boolean containsKey(short key)
Returns true if the key is in the set.- Specified by:
containsKeyin interfaceShortKeySet- Parameters:
key- the key whose presence is to be tested.- Returns:
- true if the key is in the set.
- Throws:
java.lang.IndexOutOfBoundsException- thrown if the given key is not in the range [0, maxKey].
-
getFirst
public short getFirst()
Returns the first key in this set.- Specified by:
getFirstin interfaceShortKeySet
-
getLast
public short getLast()
Returns the last key in this set.- Specified by:
getLastin interfaceShortKeySet
-
getNext
public short getNext(short key)
Returns the smallest key in the set that is greater than the given key. Returns -1 if there are no keys greater than the given key.- Specified by:
getNextin interfaceShortKeySet- Parameters:
key- the key for which to find the next key after.- Throws:
java.lang.IndexOutOfBoundsException- thrown if the given key is not in the range [0, maxKey].
-
getPrevious
public short getPrevious(short key)
Returns the largest key in the set that is less than the given key. Returns -1 if there are not keys less than the given key.- Specified by:
getPreviousin interfaceShortKeySet- Parameters:
key- the key for which to find the previous key.- Throws:
java.lang.IndexOutOfBoundsException- thrown if the given key is not in the range [0, maxKey].
-
put
public void put(short key)
Adds the given key to the set.- Specified by:
putin interfaceShortKeySet- Parameters:
key- the key to add to the set.- Throws:
java.lang.IndexOutOfBoundsException- thrown if the given key is not in the range [0, maxKey].
-
remove
public boolean remove(short key)
Removes the given key from the set.- Specified by:
removein interfaceShortKeySet- Parameters:
key- the key to remove from the set.- Throws:
java.lang.IndexOutOfBoundsException- thrown if the given key is not in the range [0, maxKey].
-
removeAll
public void removeAll()
Removes all keys from the set.- Specified by:
removeAllin interfaceShortKeySet
-
isEmpty
public boolean isEmpty()
Test if the set is empty.- Specified by:
isEmptyin interfaceShortKeySet- Returns:
- true if the set is empty.
-
-