Class MutableSparseIntSet

  • All Implemented Interfaces:
    IntSet, MutableIntSet, java.io.Serializable
    Direct Known Subclasses:
    TunedMutableSparseIntSet

    public class MutableSparseIntSet
    extends SparseIntSet
    implements MutableIntSet
    A sparse ordered, mutable duplicate-free, fully-encapsulated set of integers. Instances are not canonical, except for EMPTY. This implementation will be inefficient if these sets get large. TODO: even for small sets, we probably want to work on this to reduce the allocation activity.
    See Also:
    Serialized Form
    • Constructor Detail

      • MutableSparseIntSet

        protected MutableSparseIntSet​(IntSet set)
      • MutableSparseIntSet

        protected MutableSparseIntSet​(int[] backingStore)
      • MutableSparseIntSet

        protected MutableSparseIntSet()
    • Method Detail

      • clear

        public void clear()
        Description copied from interface: MutableIntSet
        remove all elements from this set
        Specified by:
        clear in interface MutableIntSet
      • remove

        public boolean remove​(int value)
        Description copied from interface: MutableIntSet
        Remove an integer from this set.
        Specified by:
        remove in interface MutableIntSet
        Parameters:
        value - integer to remove
        Returns:
        true iff the value of this changes.
      • getInitialNonEmptySize

        public int getInitialNonEmptySize()
      • getExpansionFactor

        public float getExpansionFactor()
      • add

        public boolean add​(int value)
        Description copied from interface: MutableIntSet
        Add an integer value to this set.
        Specified by:
        add in interface MutableIntSet
        Parameters:
        value - integer to add
        Returns:
        true iff this value changes
      • copySet

        public void copySet​(IntSet that)
                     throws java.lang.IllegalArgumentException
        Description copied from interface: MutableIntSet
        Set the value of this to be the same as the value of set
        Specified by:
        copySet in interface MutableIntSet
        Throws:
        java.lang.IllegalArgumentException - if that == null
      • intersectWith

        public void intersectWith​(SparseIntSet set)
      • addAll

        public boolean addAll​(IntSet set)
                       throws java.lang.IllegalArgumentException
        Add all elements from another int set.
        Specified by:
        addAll in interface MutableIntSet
        Returns:
        true iff this set changes
        Throws:
        java.lang.IllegalArgumentException - if set == null
      • addAll

        public boolean addAll​(SparseIntSet that)
        Add all elements from another int set.
        Returns:
        true iff this set changes
      • removeAll

        public <T extends BitVectorBase<T>> void removeAll​(T v)
      • removeAll

        public void removeAll​(MutableSparseIntSet set)
        TODO optimize
        Throws:
        java.lang.IllegalArgumentException - if set is null
      • createMutableSparseIntSet

        public static MutableSparseIntSet createMutableSparseIntSet​(int initialCapacity)
                                                             throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException