Class TokenMap

All Implemented Interfaces:
Iterable<byte[]>
Direct Known Subclasses:
StemDir

public class TokenMap extends TokenSet
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
  • 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 - key
      value - value
    • put

      public final void put(String key, String value)
      Convenience function for adding strings, which will be converted to tokens.
      Parameters:
      key - key
      value - 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 null if nothing was found
    • remove

      public int remove(byte[] key)
      Description copied from class: TokenSet
      Removes the entry with the specified key. The deletion of keys will lead to empty entries. If ASet.size is called after deletions, the original number of entries will be returned.
      Overrides:
      remove in class TokenSet
      Parameters:
      key - key
      Returns:
      id of the deleted key, or 0 if the key did not exist
    • values

      public final Iterable<byte[]> values()
      Returns a value iterator.
      Returns:
      iterator
    • clear

      public final void clear()
      Description copied from class: ASet
      Resets the data structure.
      Overrides:
      clear in class TokenSet
    • rehash

      protected final void rehash(int newSize)
      Description copied from class: ASet
      Rehashes all entries.
      Overrides:
      rehash in class TokenSet
      Parameters:
      newSize - new hash size
    • toString

      public String toString()
      Overrides:
      toString in class TokenSet