Class StateSet


  • final class StateSet
    extends IntSet
    A thin wrapper of IntIntHashMap Maps from state in integer representation to its reference count Whenever the count of a state is 0, that state will be removed from the set
    • Constructor Summary

      Constructors 
      Constructor Description
      StateSet​(int capacity)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void decr​(int state)
      Decrease the reference count of the state, if the count down to 0, remove the state from this set
      (package private) FrozenIntSet freeze​(int state)
      Create a snapshot of this int set associated with a given state.
      (package private) int[] getArray()
      Return an array representation of this int set's values.
      (package private) void incr​(int state)
      Add the state into this set, if it is already there, increase its reference count by 1
      private void keyChanged()  
      (package private) long longHashCode()  
      (package private) int size()
      Guaranteed to be less than or equal to the length of the array returned by IntSet.getArray().
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • hashCode

        private long hashCode
      • hashUpdated

        private boolean hashUpdated
      • arrayUpdated

        private boolean arrayUpdated
      • arrayCache

        private int[] arrayCache
    • Constructor Detail

      • StateSet

        StateSet​(int capacity)
    • Method Detail

      • incr

        void incr​(int state)
        Add the state into this set, if it is already there, increase its reference count by 1
        Parameters:
        state - an integer representing this state
      • decr

        void decr​(int state)
        Decrease the reference count of the state, if the count down to 0, remove the state from this set
        Parameters:
        state - an integer representing this state
      • freeze

        FrozenIntSet freeze​(int state)
        Create a snapshot of this int set associated with a given state. The snapshot will not retain any frequency information about the elements of this set, only existence.
        Parameters:
        state - the state to associate with the frozen set.
        Returns:
        A new FrozenIntSet with the same values as this set.
      • keyChanged

        private void keyChanged()
      • getArray

        int[] getArray()
        Description copied from class: IntSet
        Return an array representation of this int set's values. Values are valid for indices [0, IntSet.size()). If this is a mutable int set, then changes to the set are not guaranteed to be visible in this array.
        Specified by:
        getArray in class IntSet
        Returns:
        an array containing the values for this set, guaranteed to be at least IntSet.size() elements
      • size

        int size()
        Description copied from class: IntSet
        Guaranteed to be less than or equal to the length of the array returned by IntSet.getArray().
        Specified by:
        size in class IntSet
        Returns:
        The number of values in this set.