Package org.jibx.util

Class StringSizedSet


  • public class StringSizedSet
    extends Object
    Fixed size hash set of String values.
    Author:
    Dennis M. Sosnoski
    • Field Detail

      • DEFAULT_FILL_FRACTION

        public static final double DEFAULT_FILL_FRACTION
        Default fill fraction for sizing of tables.
        See Also:
        Constant Field Values
      • m_arraySize

        protected final int m_arraySize
        Size of array used for keys.
      • m_keyTable

        protected final String[] m_keyTable
        Array of key table slots.
      • m_hitOffset

        protected final int m_hitOffset
        Offset added (modulo table size) to slot number on collision.
    • Constructor Detail

      • StringSizedSet

        public StringSizedSet​(int count,
                              double fill)
        Constructor with full specification.
        Parameters:
        count - number of values to assume in sizing of table
        fill - fraction fill for table (maximum of 0.7, to prevent excessive collisions)
      • StringSizedSet

        public StringSizedSet​(int count)
        Constructor with only value count specified. Uses default fill fraction and miss value.
        Parameters:
        count - number of values to assume in initial sizing of table
    • Method Detail

      • add

        public boolean add​(String key)
        Add a key to the set. If the key is already present in the set, this does nothing.
        Parameters:
        key - key to be added to table (non-null)
        Returns:
        true if added, false if already present value if key not previously present in table
      • contains

        public final boolean contains​(String key)
        Check if an entry is present in the table.
        Parameters:
        key - key to be found
        Returns:
        true if key found in table, false if not
      • clear

        public void clear()
        Set the table to the empty state.