Package org.basex.util.hash
Class TokenMap
java.lang.Object
org.basex.util.hash.ASet
org.basex.util.hash.TokenSet
org.basex.util.hash.TokenMap
- All Implemented Interfaces:
Iterable<byte[]>
- Direct Known Subclasses:
StemDir
This is an efficient and memory-saving hash map for storing tokens.
It extends the
TokenSet class.- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclear()Resets the data structure.final byte[]get(byte[] key) Returns the value for the specified key.final voidput(byte[] key, byte[] value) Stores the specified key and value.final voidConvenience function for adding strings, which will be converted to tokens.protected final voidrehash(int newSize) Rehashes all entries.intremove(byte[] key) Removes the entry with the specified key.toString()final Iterable<byte[]>values()Returns a value iterator.Methods inherited from class org.basex.util.hash.TokenSet
add, add, contains, hash, id, iterator, key, put, read, writeMethods 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
-
TokenMap
public TokenMap()Default constructor.
-
-
Method Details
-
put
public final void put(byte[] key, byte[] value) Stores the specified key and value. If the key exists, the value is updated.- Parameters:
key- keyvalue- value
-
put
Convenience function for adding strings, which will be converted to tokens.- Parameters:
key- keyvalue- value
-
get
public final byte[] get(byte[] key) Returns the value for the specified key.- Parameters:
key- key to be looked up- Returns:
- value, or
nullif nothing was 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. -
values
Returns a value iterator.- Returns:
- iterator
-
clear
public final void clear()Description copied from class:ASetResets the data structure. -
rehash
protected final void rehash(int newSize) Description copied from class:ASetRehashes all entries. -
toString
-