Class HashItemSet

java.lang.Object
org.basex.util.hash.ASet
org.basex.query.util.hash.HashItemSet
All Implemented Interfaces:
Iterable<Item>, ItemSet

public final class HashItemSet extends ASet implements ItemSet
This is an efficient and memory-saving hash map for storing items.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Constructor Details

    • HashItemSet

      public HashItemSet(boolean eq)
      Default constructor.
      Parameters:
      eq - equality check
  • Method Details

    • add

      public boolean add(Item item, 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:
      item - key to be added
      ii - input info (can be null)
      Returns:
      true if the key did not exist yet and was stored
      Throws:
      QueryException - query exception
    • contains

      public boolean contains(Item item, InputInfo ii) throws QueryException
      Checks if the specified item exists.
      Parameters:
      item - item to look up
      ii - input info (can be null)
      Returns:
      result of check
      Throws:
      QueryException - query exception
    • id

      public int id(Item item, InputInfo ii) throws QueryException
      Returns the id of the specified QName, or 0 if the QName does not exist.
      Parameters:
      item - item to look up
      ii - input info (can be null)
      Returns:
      id, or 0 if QName does not exist
      Throws:
      QueryException - query exception
    • 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
    • iterator

      public Iterator<Item> iterator()
      Specified by:
      iterator in interface Iterable<Item>
    • toString

      public String toString()
      Overrides:
      toString in class Object