org.basex.util.hash
Class TokenIntMap

java.lang.Object
  extended by org.basex.util.hash.ASet
      extended by org.basex.util.hash.TokenSet
          extended by org.basex.util.hash.TokenIntMap
All Implemented Interfaces:
java.lang.Iterable<byte[]>

public final class TokenIntMap
extends TokenSet

This is an efficient and memory-saving hash map for storing tokens and integers.

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
TokenIntMap()
          Constructor.
TokenIntMap(DataInput in)
          Constructor.
 
Method Summary
 int get(byte[] key)
          Returns the value for the specified key.
 void put(byte[] key, int value)
          Indexes the specified key and stores the associated value.
 void read(DataInput in)
          Reads the data structure from the specified input.
protected  void rehash(int s)
          Rehashes all entries.
 void write(DataOutput out)
          Writes the data structure to the specified output.
 
Methods inherited from class org.basex.util.hash.TokenSet
add, add, clear, contains, delete, hash, id, iterator, key, put, toString
 
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

TokenIntMap

public TokenIntMap()
Constructor.


TokenIntMap

public TokenIntMap(DataInput in)
            throws java.io.IOException
Constructor.

Parameters:
in - input stream
Throws:
java.io.IOException - I/O exception
Method Detail

read

public void read(DataInput in)
          throws java.io.IOException
Description copied from class: TokenSet
Reads the data structure from the specified input.

Overrides:
read in class TokenSet
Parameters:
in - input stream
Throws:
java.io.IOException - I/O exception

write

public void write(DataOutput out)
           throws java.io.IOException
Description copied from class: TokenSet
Writes the data structure to the specified output.

Overrides:
write in class TokenSet
Parameters:
out - output stream
Throws:
java.io.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 - key
value - value

get

public int get(byte[] key)
Returns the value for the specified key.

Parameters:
key - key to be looked up
Returns:
value, or -1 if the key was not found

rehash

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

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