Class QNmSet

  • All Implemented Interfaces:
    Iterable<QNm>
    Direct Known Subclasses:
    QNmMap

    public class QNmSet
    extends ASet
    implements Iterable<QNm>
    This is an efficient and memory-saving hash set for storing QNames. It is derived from the TokenSet class.
    Author:
    BaseX Team 2005-24, BSD License, Christian Gruen
    • Field Detail

      • keys

        protected QNm[] keys
        Hashed keys.
    • Constructor Detail

      • QNmSet

        public QNmSet()
        Default constructor.
    • Method Detail

      • add

        public final boolean add​(QNm key)
        Stores the specified key if it has not been stored before.
        Parameters:
        key - key to be added
        Returns:
        true if the key did not exist yet and was stored
      • put

        public final int put​(QNm key)
        Stores the specified key and returns its id.
        Parameters:
        key - key to be added
        Returns:
        unique id of stored key (larger than zero)
      • contains

        public final boolean contains​(QNm key)
        Checks if the set contains the specified key.
        Parameters:
        key - key to be looked up
        Returns:
        result of check
      • id

        public final int id​(QNm key)
        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
      • key

        public final QNm key​(int id)
        Returns the key with the specified id. All ids start with 1 instead of 0.
        Parameters:
        id - id of the key to return
        Returns:
        key
      • hash

        protected final 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