Package ghidra.util.datastruct
Class StringIntHashtable
- java.lang.Object
-
- ghidra.util.datastruct.StringIntHashtable
-
- All Implemented Interfaces:
java.io.Serializable
public class StringIntHashtable extends java.lang.Object implements java.io.Serializable
Class that implements a hashtable with String keys and int values.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description StringIntHashtable()
Default constructor creates a table with an initial default capacity.StringIntHashtable(int capacity)
Constructor creates a table with an initial given capacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(java.lang.String key)
Return true if the given key is in the hashtable.int
get(java.lang.String key)
Returns the value for the given key.java.util.Iterator<java.lang.String>
getKeyIterator()
Returns an iterator over the strings in this hash table.java.lang.String[]
getKeys()
Returns an array containing all the String keys.void
put(java.lang.String key, int value)
Adds a key/value pair to the hashtable.boolean
remove(java.lang.String key)
Removes a key from the hashtablevoid
removeAll()
Remove all entries from the hashtable.int
size()
Return the number of key/value pairs stored in the hashtable.
-
-
-
Constructor Detail
-
StringIntHashtable
public StringIntHashtable()
Default constructor creates a table with an initial default capacity.
-
StringIntHashtable
public StringIntHashtable(int capacity)
Constructor creates a table with an initial given capacity. The capacity will be adjusted to the next highest prime in the PRIMES table.- Parameters:
capacity
- the initial capacity.
-
-
Method Detail
-
getKeyIterator
public java.util.Iterator<java.lang.String> getKeyIterator()
Returns an iterator over the strings in this hash table.
-
put
public void put(java.lang.String key, int value)
Adds a key/value pair to the hashtable. If the key is already in the table, the old value is replaced with the new value. If the hashtable is already full, the hashtable will attempt to approximately double in size (it will use a prime number), and all the current entries will be rehashed.- Parameters:
key
- the key to associate with the given value.value
- the value to associate with the given key.- Throws:
java.lang.ArrayIndexOutOfBoundsException
- thrown if the maximum capacity is reached.
-
get
public int get(java.lang.String key) throws NoValueException
Returns the value for the given key.- Parameters:
key
- the key whose associated value is to be returned.- Throws:
NoValueException
- thrown if there is no value for the given key.
-
remove
public boolean remove(java.lang.String key)
Removes a key from the hashtable- Parameters:
key
- key to be removed from the hashtable.- Returns:
- true if key is found and removed, false otherwise.
-
removeAll
public void removeAll()
Remove all entries from the hashtable.
-
contains
public boolean contains(java.lang.String key)
Return true if the given key is in the hashtable.- Parameters:
key
- the key whose presence in this map is to be tested.
-
size
public int size()
Return the number of key/value pairs stored in the hashtable.
-
getKeys
public java.lang.String[] getKeys()
Returns an array containing all the String keys.
-
-