Class HashItemSet

  • All Implemented Interfaces:
    Iterable<Item>, ItemSet

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

      • HashItemSet

        public HashItemSet​(boolean eq,
                           InputInfo info)
        Default constructor.
        Parameters:
        eq - equality check
        info - input info (can be null)
    • Method Detail

      • add

        public boolean add​(Item key)
                    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
        Returns:
        true if the key did not exist yet and was stored
        Throws:
        QueryException - query exception
      • contains

        public boolean contains​(Item key)
                         throws QueryException
        Checks if the set contains the specified key.
        Parameters:
        key - key to be looked up
        Returns:
        result of check
        Throws:
        QueryException - query exception
      • id

        public int id​(Item key)
               throws QueryException
        Returns the id of the specified key, or 0 if the key does not exist.
        Parameters:
        key - key to be looked up
        Returns:
        id, or 0 if key 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