org.basex.util.hash
Class TokenMap

java.lang.Object
  extended by org.basex.util.hash.ASet
      extended by org.basex.util.hash.TokenSet
          extended by org.basex.util.hash.TokenMap
All Implemented Interfaces:
java.lang.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-13, BSD License, Christian Gruen

Field Summary
 
Fields inherited from class org.basex.util.hash.TokenSet
keys
 
Fields inherited from class org.basex.util.hash.ASet
bucket, next, size
 
Constructor Summary
TokenMap()
           
 
Method Summary
 int delete(byte[] key)
          Deletes the specified key.
 byte[] get(byte[] key)
          Returns the value for the specified key.
 void put(byte[] key, byte[] value)
          Stores the specified key and value.
 void put(java.lang.String key, java.lang.String value)
          Convenience function for adding strings, which will be converted to tokens.
protected  void rehash(int s)
          Rehashes all entries.
 java.lang.String toString()
           
 java.lang.Iterable<byte[]> values()
          Returns a value iterator.
 
Methods inherited from class org.basex.util.hash.TokenSet
add, add, clear, contains, hash, id, iterator, key, put, read, write
 
Methods inherited from class org.basex.util.hash.ASet
checkSize, isEmpty, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TokenMap

public TokenMap()
Method Detail

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(java.lang.String key,
                      java.lang.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

delete

public int delete(byte[] key)
Description copied from class: TokenSet
Deletes 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:
delete in class TokenSet
Parameters:
key - key
Returns:
deleted key or 0

values

public final java.lang.Iterable<byte[]> values()
Returns a value iterator.

Returns:
iterator

rehash

protected final void rehash(int s)
Description copied from class: ASet
Rehashes all entries.

Overrides:
rehash in class TokenSet
Parameters:
s - new hash size

toString

public final java.lang.String toString()
Overrides:
toString in class TokenSet