Class IntSets


  • public class IntSets
    extends Object
    Static utility class for creating various IntSet objects.
    Since:
    9.3
    Author:
    wburns
    • Method Detail

      • immutableEmptySet

        public static IntSet immutableEmptySet()
        Returns an immutable IntSet containing no values
        Returns:
        IntSet with no values
      • immutableSet

        public static IntSet immutableSet​(int value)
        Returns an immutable IntSet containing a single value
        Parameters:
        value - the value to be set on the IntSet
        Returns:
        IntSet with just the 1 value
      • immutableSet

        public static IntSet immutableSet​(IntSet set)
        Returns an immutable IntSet that wraps the given IntSet to prevent modifications.
        Parameters:
        set - set to wrap
        Returns:
        immutable IntSet
      • immutableRangeSet

        public static IntSet immutableRangeSet​(int endExclusive)
        Returns an immutable IntSet containing all values from 0 to endExclusive - 1.
        Parameters:
        endExclusive - the exclusive upper bound
        Returns:
        IntSet with the values in the given range available
      • from

        public static IntSet from​(Set<Integer> integerSet)
        Returns an IntSet based on the provided Set. This method tries to return or create the most performant IntSet based on the Set provided. If the Set is already an IntSet it will just return that. The returned IntSet may or may not be immutable, so no guarantees are provided from that respect.
        Parameters:
        integerSet - IntSet to create from
        Returns:
        the IntSet that is equivalent to the Set
      • from

        public static IntSet from​(PrimitiveIterator.OfInt iterator)
        Returns an IntSet based on the ints in the iterator. This method will try to return the most performant IntSet based on what ints are provided if any. The returned IntSet may or may not be immutable, so no guarantees are provided from that respect.
        Parameters:
        iterator - values set in the returned set
        Returns:
        IntSet with all the values set that the iterator had
      • mutableFrom

        public static IntSet mutableFrom​(Set<Integer> integerSet)
        Returns an IntSet that is mutable that contains all of the values from the given set. If this provided Set is already an IntSet and mutable it will return the same object.
        Parameters:
        integerSet - set to use values from
        Returns:
        IntSet that is mutable with the values set
      • mutableCopyFrom

        public static IntSet mutableCopyFrom​(Set<Integer> mutableSet)
        Returns an IntSet that contains all ints from the given Set that is mutable. Updates to the original Set or the returned IntSet are not reflected in the other.
        Parameters:
        mutableSet - set to copy from
        Returns:
        IntSet with the values set
      • mutableEmptySet

        public static IntSet mutableEmptySet​(int maxExclusive)
        Returns an IntSet that contains no values but is initialized to hold ints equal to the maxExclusive -1 or smaller.
        Parameters:
        maxExclusive - largest int expected in set
        Returns:
        IntSet with no values set
      • mutableEmptySet

        public static IntSet mutableEmptySet()
        Returns a mutable IntSet with no values set. Note this mutable set is initialized given a default size. If you wish to not have less initialization over, please use mutableEmptySet(int) providing a 0 or similar.
        Returns:
        IntSet with no values set
      • mutableSet

        public static IntSet mutableSet​(int value)
        Returns a mutable set with the initial value set. This set is optimized to insert values less than this. Values added that are larger may require additional operations.
        Parameters:
        value - the value to set
        Returns:
        IntSet with the value set
      • mutableSet

        public static IntSet mutableSet​(int value1,
                                        int value2)
        Returns a mutable IntSet that begins with the initialized values
        Parameters:
        value1 -
        value2 -
        Returns:
      • concurrentSet

        public static IntSet concurrentSet​(int maxExclusive)
        Returns a concurrent mutable IntSet that can store values in the range of 0..maxExclusive-1
        Parameters:
        maxExclusive - the maximum value - 1 that can be inserted into the set
        Returns:
        concurrent set
      • concurrentCopyFrom

        public static IntSet concurrentCopyFrom​(IntSet intSet,
                                                int maxExclusive)
        Returns a copy of the given set that supports concurrent operations. The returned set will contain all of the ints the provided set contained. The returned set only supports up to the maximum size the previous int set supported when this method is invoked or the largest int it held.
        Parameters:
        intSet - set to copy from
        maxExclusive - the maximum value - 1 that can be inserted into the set
        Returns:
        concurrent copy