Package org.basex.util.hash
Class TokenIntMap
java.lang.Object
org.basex.util.hash.ASet
org.basex.util.hash.TokenSet
org.basex.util.hash.TokenIntMap
- All Implemented Interfaces:
Iterable<byte[]>
This is an efficient and memory-saving hash map for storing tokens and integers.
- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintget(byte[] key) Returns the value for the specified key.voidput(byte[] key, int value) Indexes the specified key and stores the associated value.voidReads the data structure from the specified input.protected voidrehash(int newSize) Rehashes all entries.intremove(byte[] key) Removes the entry with the specified key.toString()voidwrite(DataOutput out) Writes the data structure to the specified output.Methods inherited from class org.basex.util.hash.TokenSet
add, add, clear, contains, hash, id, iterator, key, putMethods inherited from class org.basex.util.hash.ASet
capacity, checkSize, isEmpty, size, toString, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
TokenIntMap
public TokenIntMap()Constructor. -
TokenIntMap
Constructor.- Parameters:
in- input stream- Throws:
IOException- I/O exception
-
-
Method Details
-
read
Description copied from class:TokenSetReads the data structure from the specified input.- Overrides:
readin classTokenSet- Parameters:
in- input stream- Throws:
IOException- I/O exception
-
write
Description copied from class:TokenSetWrites the data structure to the specified output.- Overrides:
writein classTokenSet- Parameters:
out- output stream- Throws:
IOException- I/O exception
-
put
public void put(byte[] key, int value) Indexes the specified key and stores the associated value. If the key already exists, the value is updated.- Parameters:
key- keyvalue- value
-
get
public int get(byte[] key) Returns the value for the specified key.- Parameters:
key- key to be looked up- Returns:
- value, or
-1if the key was not found
-
remove
public int remove(byte[] key) Description copied from class:TokenSetRemoves the entry with the specified key. The deletion of keys will lead to empty entries. IfASet.sizeis called after deletions, the original number of entries will be returned. -
rehash
protected void rehash(int newSize) Description copied from class:ASetRehashes all entries. -
toString
-