Class ConcurrentSmallIntSet
java.lang.Object
org.infinispan.commons.util.ConcurrentSmallIntSet
Concurrent implementation of an
IntSet
. This implementation is limited in that it can only inserts ints up
to an initialized maximum. Any attempt to insert/remove a larger value will result in an
IllegalArgumentException
thrown. Note that operations spanning multiple values (ie.
containsAll(IntSet)
, removeAll(IntSet)
) are not performed atomically and are done on a per value
basis.- Since:
- 9.3
- Author:
- wburns
-
Constructor Summary
ConstructorsConstructorDescriptionConcurrentSmallIntSet
(int maxCapacityExclusive) Creates a new, empty map which can accommodate ints in value up tomaxCapacityExclusive - 1
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(int i) Adds the given int to this set and returnstrue
if it was set orfalse
if it was already presentboolean
boolean
addAll
(Collection<? extends Integer> c) boolean
Adds all ints from the provided set into this onevoid
clear()
boolean
contains
(int i) Whether this set contains the given intboolean
boolean
containsAll
(Collection<?> c) boolean
containsAll
(IntSet set) Whether this set contains all ints in the given IntSetboolean
void
void
forEach
(IntConsumer action) Performs the given action for each int of theIntSet
until all elements have been processed or the action throws an exception.int
hashCode()
Creates aSpliterator.OfInt
over the ints in this set.A stream of ints representing the data in this setboolean
isEmpty()
iterator()
A primtive iterator that allows iteration over the int values.int
nextSetBit
(int fromIndex) Returns the next int in the set that is greater than or equal to the given value.boolean
remove
(int i) Removes, if present, the int from the set and returns if it was present or notboolean
boolean
removeAll
(Collection<?> c) boolean
Removes all ints from this IntSet that are in the provided IntSetboolean
removeIf
(IntPredicate filter) Removes all the ints of this set that satisfy the given predicate.boolean
boolean
retainAll
(Collection<?> c) boolean
Modifies this set to remove all ints that are not present in the provided IntSetvoid
set
(int i) Adds or sets the int without returning whether it was previously setint
size()
final Object[]
toArray()
final <T> T[]
toArray
(T[] a) byte[]
toBitSet()
Returns a byte array that has a bit set for each int in this set where each byte represents 8 numbers.int[]
Returns an array containing all of the elements in this set.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, toArray
Methods inherited from interface java.util.Set
spliterator
-
Constructor Details
-
ConcurrentSmallIntSet
public ConcurrentSmallIntSet(int maxCapacityExclusive) Creates a new, empty map which can accommodate ints in value up tomaxCapacityExclusive - 1
. This number will be rounded up to the nearest 32.- Parameters:
maxCapacityExclusive
- The implementation performs sizing to ensure values up to this can be stored
-
-
Method Details
-
nextSetBit
public int nextSetBit(int fromIndex) Description copied from interface:IntSet
Returns the next int in the set that is greater than or equal to the given value.- Specified by:
nextSetBit
in interfaceIntSet
- Parameters:
fromIndex
- : inclusive index to start searching.- Returns:
- the index of the next set bit, or -1 if there is no such bit
-
add
-
set
-
remove
-
contains
-
addAll
-
containsAll
Description copied from interface:IntSet
Whether this set contains all ints in the given IntSet- Specified by:
containsAll
in interfaceIntSet
- Parameters:
set
- the set to check if all are present- Returns:
- if the set contains all the ints
-
removeAll
-
retainAll
-
size
-
isEmpty
-
contains
-
iterator
Description copied from interface:IntSet
A primtive iterator that allows iteration over the int values. This iterator supports removal if the set is modifiable. -
toArray
-
toArray
-
add
-
remove
-
containsAll
- Specified by:
containsAll
in interfaceCollection<Integer>
- Specified by:
containsAll
in interfaceSet<Integer>
-
addAll
-
retainAll
-
removeAll
-
clear
-
intStream
-
intSpliterator
Description copied from interface:IntSet
Creates aSpliterator.OfInt
over the ints in this set.The
Spliterator.OfInt
reportsSpliterator.DISTINCT
. Implementations should document the reporting of additional characteristic values. The default implementation creates a late-binding spliterator from the set'sIterator
. The spliterator inherits the fail-fast properties of the set's iterator.The created
Spliterator.OfInt
additionally reportsSpliterator.SIZED
. The createdSpliterator.OfInt
additionally reportsSpliterator.SUBSIZED
.- Specified by:
intSpliterator
in interfaceIntSet
- Returns:
- a
Spliterator.OfInt
over the ints in this set
-
toIntArray
public int[] toIntArray()Description copied from interface:IntSet
Returns an array containing all of the elements in this set. If this set makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.- Specified by:
toIntArray
in interfaceIntSet
- Returns:
- this int set as an array
-
toBitSet
public byte[] toBitSet()Description copied from interface:IntSet
Returns a byte array that has a bit set for each int in this set where each byte represents 8 numbers. That is if the ints 2, 5 and 9 are set this will return a byte array consisting of 2 bytes in little-endian representation of those values.Depending upon the implementation this array may or may not have trailing bytes and may be condensed to save space.
-
forEach
-
forEach
Description copied from interface:IntSet
Performs the given action for each int of theIntSet
until all elements have been processed or the action throws an exception. Unless otherwise specified by the implementing class, actions are performed in the order of iteration (if an iteration order is specified). Exceptions thrown by the action are relayed to the caller.The default implementation behaves as if:
PrimitiveIterator.OfInt iterator = iterator(); while (iterator.hasNext()) { action.accept(iterator.nextInt()); }
-
removeIf
- Specified by:
removeIf
in interfaceCollection<Integer>
-
removeIf
Description copied from interface:IntSet
Removes all the ints of this set that satisfy the given predicate. Errors or runtime exceptions thrown during iteration or by the predicate are relayed to the caller. The default implementation traverses all elements of the collection using itsIntSet.iterator()
. Each matching element is removed usingIterator.remove()
. If the collection's iterator does not support removal then anUnsupportedOperationException
will be thrown on the first matching element. -
equals
-
hashCode
-
toString
-