org.basex.query.util
Class HashItemSet

java.lang.Object
  extended by org.basex.util.hash.ASet
      extended by org.basex.query.util.HashItemSet
All Implemented Interfaces:
java.lang.Iterable<Item>, ItemSet
Direct Known Subclasses:
ItemValueMap

public class HashItemSet
extends ASet
implements ItemSet

This is an efficient and memory-saving hash map for storing items. It is related to the TokenSet class.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Field Summary
 
Fields inherited from class org.basex.util.hash.ASet
bucket, next, size
 
Constructor Summary
HashItemSet()
          Default constructor.
 
Method Summary
 boolean add(Item key, InputInfo ii)
          Stores the specified key if it has not been stored before.
protected  int hash(int id)
          Returns the hash value of the element with the specified id.
 int id(Item key, InputInfo ii)
          Returns the id of the specified key, or 0 if the key does not exist.
 java.util.Iterator<Item> iterator()
           
 int put(Item key, InputInfo ii)
          Stores the specified key and returns its id.
protected  void rehash(int newSize)
          Rehashes all entries.
 
Methods inherited from class org.basex.util.hash.ASet
checkSize, clear, isEmpty, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashItemSet

public HashItemSet()
Default constructor.

Method Detail

add

public final boolean add(Item key,
                         InputInfo ii)
                  throws QueryException
Description copied from interface: ItemSet
Stores the specified key if it has not been stored before.

Specified by:
add in interface ItemSet
Parameters:
key - key to be added
ii - input info
Returns:
if the key did not exist yet and was stored
Throws:
QueryException - query exception

put

public int put(Item key,
               InputInfo ii)
        throws QueryException
Stores the specified key and returns its id.

Parameters:
key - key to be added
ii - input info
Returns:
unique id of stored key (larger than zero)
Throws:
QueryException - query exception

id

public final int id(Item key,
                    InputInfo ii)
             throws QueryException
Returns the id of the specified key, or 0 if the key does not exist.

Parameters:
key - key to be looked up
ii - input info
Returns:
id, or 0 if key does not exist
Throws:
QueryException - query exception

iterator

public java.util.Iterator<Item> iterator()
Specified by:
iterator in interface java.lang.Iterable<Item>

hash

protected int hash(int id)
Description copied from class: ASet
Returns the hash value of the element with the specified id.

Specified by:
hash in class ASet
Parameters:
id - id of the element
Returns:
hash value

rehash

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

Specified by:
rehash in class ASet
Parameters:
newSize - new hash size