Top Fields Constructors Methods
com.vladsch.flexmark.experimental.util.collection

public Class BitIntegerSet

extends Object
implements Set<Integer>, ReversibleIterable<Integer>
Class Inheritance
All Implemented Interfaces
com.vladsch.flexmark.util.collection.iteration.ReversibleIterable, java.lang.Iterable, java.util.Set, java.util.Collection
Imports
com.vladsch.flexmark.util.collection.iteration.BitSetIterator, .ReversibleIterable, .ReversibleIterator, org.jetbrains.annotations.NotNull, .Nullable, java.lang.reflect.Array, java.nio.ByteBuffer, .LongBuffer, java.util.BitSet, .Collection, .Set, java.util.function.Consumer, .IntConsumer

Field Summary

Modifier and TypeField and Description
public static final int[]
private final @NotNull BitSet
private final boolean

Constructor Summary

AccessConstructor and Description
public
public
public
public
private
BitIntegerSet(@NotNull BitIntegerSet other, boolean reversed)

Method Summary

Modifier and TypeMethod and Description
public boolean
add(@NotNull Integer
element to be added to this set
item
)

Implements java.util.Set.add.

Adds the specified element to this set if it is not already present (optional operation).

public boolean
addAll(int... collection)

public boolean
addAll(@NotNull int[] collection, int startIndex)

public boolean
addAll(@NotNull int[] collection, int startIndex, int endIndex)

public boolean
addAll(@NotNull Collection<? extends Integer>
collection containing elements to be added to this set
collection
)

Implements java.util.Set.addAll.

Adds all of the elements in the specified collection to this set if they're not already present (optional operation).

public @NotNull BitIntegerSet
public @NotNull BitIntegerSet
public @NotNull BitIntegerSet
public @NotNull BitIntegerSet
public @NotNull BitSet
public int
public int
cardinality(int start)

public int
cardinality(int start, int end)

public void
clear()

Implements java.util.Set.clear.

Removes all of the elements from this set (optional operation).

public @NotNull BitIntegerSet
clear(int i)

public @NotNull BitIntegerSet
clear(int i, int i1)

public boolean
contains(@Nullable Object
element whose presence in this set is to be tested
o
)

Implements java.util.Set.contains.

Returns true if this set contains the specified element.

public boolean
containsAll(@NotNull Collection<?>
collection to be checked for containment in this set
collection
)

Implements java.util.Set.containsAll.

Returns true if this set contains all of the elements of the specified collection.

public @NotNull BitIntegerSet
flip(int i)

public @NotNull BitIntegerSet
flip(int i, int i1)

public void
forEach(@NotNull Consumer<? super Integer>
The action to be performed for each element
consumer
)

Overrides default java.lang.Iterable.forEach.

Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.

public void
public boolean
get(int i)

public @NotNull BitIntegerSet
get(int i, int i1)

public boolean
public boolean
isEmpty()

Implements java.util.Set.isEmpty.

Returns true if this set contains no elements.

public boolean
public @NotNull ReversibleIterator<Integer>
public int
nextClearBit(int i)

public int
nextSetBit(int i)

public @NotNull BitIntegerSet
public @NotNull BitIntegerSet
public int
public int
public boolean
remove(@Nullable Object
object to be removed from this set, if present
o
)

Implements java.util.Set.remove.

Removes the specified element from this set if it is present (optional operation).

public boolean
removeAll(@NotNull Collection<?>
collection containing elements to be removed from this set
collection
)

Implements java.util.Set.removeAll.

Removes from this set all of its elements that are contained in the specified collection (optional operation).

public boolean
retainAll(@NotNull Collection<?>
collection containing elements to be retained in this set
collection
)

Implements java.util.Set.retainAll.

Retains only the elements in this set that are contained in the specified collection (optional operation).

public @NotNull ReversibleIterable<Integer>
public @NotNull ReversibleIterator<Integer>
public @NotNull BitIntegerSet
set(int i)

public @NotNull BitIntegerSet
set(int i, boolean b)

public @NotNull BitIntegerSet
set(int i, int i1)

public @NotNull BitIntegerSet
set(int i, int i1, boolean b)

public int
size()

Implements java.util.Set.size.

Returns the number of elements in this set (its cardinality).

public @NotNull Object[]
toArray()

Implements java.util.Set.toArray.

Returns an array containing all of the elements in this set.

public <T> T[]
toArray(T[]
the array into which the elements of this set are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
array
)

Implements java.util.Set.toArray.

Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array.

public @NotNull int[]
toArray(@Nullable int[]
the array into which the elements of this set are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
array
)

Implements java.util.Set.toArray.

Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array.

public @NotNull int[]
toArray(@Nullable int[] array, int destinationIndex)

public @NotNull byte[]
public @NotNull long[]
public static @NotNull BitIntegerSet
valueOf(@NotNull long[] longs)

public static @NotNull BitIntegerSet
public static @NotNull BitIntegerSet
valueOf(@NotNull byte[] bytes)

public static @NotNull BitIntegerSet
public @NotNull BitIntegerSet
public @NotNull BitIntegerSet
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

EMPTY_INTback to summary
public static final int[] EMPTY_INT
myBitsback to summary
private final @NotNull BitSet myBits
Annotations
@NotNull
myReversedback to summary
private final boolean myReversed

Constructor Detail

BitIntegerSetback to summary
public BitIntegerSet()
BitIntegerSetback to summary
public BitIntegerSet(int i)
BitIntegerSetback to summary
public BitIntegerSet(@NotNull BitSet other)
BitIntegerSetback to summary
public BitIntegerSet(@NotNull BitIntegerSet other)
BitIntegerSetback to summary
private BitIntegerSet(@NotNull BitIntegerSet other, boolean reversed)

Method Detail

addback to summary
public boolean add(@NotNull Integer item)

Implements java.util.Set.add.

Doc from java.util.Set.add.

Adds the specified element to this set if it is not already present (optional operation). More formally, adds the specified element e to this set if the set contains no element e2 such that Objects.equals(e, e2). If this set already contains the element, the call leaves the set unchanged and returns false. In combination with the restriction on constructors, this ensures that sets never contain duplicate elements.

The stipulation above does not imply that sets must accept all elements; sets may refuse to add any particular element, including null, and throw an exception, as described in the specification for Collection.add. Individual set implementations should clearly document any restrictions on the elements that they may contain.

Parameters
item:@NotNull Integer

element to be added to this set

Returns:boolean

true if this set did not already contain the specified element

Annotations
@Override
addAllback to summary
public boolean addAll(int... collection)
addAllback to summary
public boolean addAll(@NotNull int[] collection, int startIndex)
addAllback to summary
public boolean addAll(@NotNull int[] collection, int startIndex, int endIndex)
addAllback to summary
public boolean addAll(@NotNull Collection<? extends Integer> collection)

Implements java.util.Set.addAll.

Doc from java.util.Set.addAll.

Adds all of the elements in the specified collection to this set if they're not already present (optional operation). If the specified collection is also a set, the addAll operation effectively modifies this set so that its value is the union of the two sets. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress.

Parameters
collection:@NotNull Collection<? extends Integer>

collection containing elements to be added to this set

Returns:boolean

true if this set changed as a result of the call

Annotations
@Override
andback to summary
public @NotNull BitIntegerSet and(@NotNull BitSet set)
Annotations
@NotNull
andback to summary
public @NotNull BitIntegerSet and(@NotNull BitIntegerSet set)
Annotations
@NotNull
andNotback to summary
public @NotNull BitIntegerSet andNot(@NotNull BitSet set)
Annotations
@NotNull
andNotback to summary
public @NotNull BitIntegerSet andNot(@NotNull BitIntegerSet set)
Annotations
@NotNull
bitSetback to summary
public @NotNull BitSet bitSet()
Annotations
@NotNull
cardinalityback to summary
public int cardinality()
cardinalityback to summary
public int cardinality(int start)
cardinalityback to summary
public int cardinality(int start, int end)
clearback to summary
public void clear()

Implements java.util.Set.clear.

Doc from java.util.Set.clear.

Removes all of the elements from this set (optional operation). The set will be empty after this call returns.

Annotations
@Override
clearback to summary
public @NotNull BitIntegerSet clear(int i)
Annotations
@NotNull
clearback to summary
public @NotNull BitIntegerSet clear(int i, int i1)
Annotations
@NotNull
containsback to summary
public boolean contains(@Nullable Object o)

Implements java.util.Set.contains.

Doc from java.util.Set.contains.

Returns true if this set contains the specified element. More formally, returns true if and only if this set contains an element e such that Objects.equals(o, e).

Parameters
o:@Nullable Object

element whose presence in this set is to be tested

Returns:boolean

true if this set contains the specified element

Annotations
@Override
containsAllback to summary
public boolean containsAll(@NotNull Collection<?> collection)

Implements java.util.Set.containsAll.

Doc from java.util.Set.containsAll.

Returns true if this set contains all of the elements of the specified collection. If the specified collection is also a set, this method returns true if it is a subset of this set.

Parameters
collection:@NotNull Collection<?>

collection to be checked for containment in this set

Returns:boolean

true if this set contains all of the elements of the specified collection

Annotations
@Override
flipback to summary
public @NotNull BitIntegerSet flip(int i)
Annotations
@NotNull
flipback to summary
public @NotNull BitIntegerSet flip(int i, int i1)
Annotations
@NotNull
forEachback to summary
public void forEach(@NotNull Consumer<? super Integer> consumer)

Overrides default java.lang.Iterable.forEach.

Doc from java.lang.Iterable.forEach.

Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception. Actions are performed in the order of iteration, if that order is specified. Exceptions thrown by the action are relayed to the caller.

The behavior of this method is unspecified if the action performs side-effects that modify the underlying source of elements, unless an overriding class has specified a concurrent modification policy.

Parameters
consumer:@NotNull Consumer<? super Integer>

The action to be performed for each element

forEachback to summary
public void forEach(@NotNull IntConsumer consumer)
getback to summary
public boolean get(int i)
getback to summary
public @NotNull BitIntegerSet get(int i, int i1)
Annotations
@NotNull
intersectsback to summary
public boolean intersects(BitSet set)
isEmptyback to summary
public boolean isEmpty()

Implements java.util.Set.isEmpty.

Doc from java.util.Set.isEmpty.

Returns true if this set contains no elements.

Returns:boolean

true if this set contains no elements

Annotations
@Override
isReversedback to summary
public boolean isReversed()

Implements com.vladsch.flexmark.util.collection.iteration.ReversibleIterable.isReversed.

Annotations
@Override
iteratorback to summary
public @NotNull ReversibleIterator<Integer> iterator()

Implements java.util.Set.iterator, com.vladsch.flexmark.util.collection.iteration.ReversibleIterable.iterator.

Doc from java.util.Set.iterator.

Returns an iterator over the elements in this set. The elements are returned in no particular order (unless this set is an instance of some class that provides a guarantee).

Returns:@NotNull ReversibleIterator<Integer>

an iterator over the elements in this set

Annotations
@Override
@NotNull
nextClearBitback to summary
public int nextClearBit(int i)
nextSetBitback to summary
public int nextSetBit(int i)
orback to summary
public @NotNull BitIntegerSet or(@NotNull BitSet set)
Annotations
@NotNull
orback to summary
public @NotNull BitIntegerSet or(@NotNull BitIntegerSet set)
Annotations
@NotNull
previousClearBitback to summary
public int previousClearBit(int i)
previousSetBitback to summary
public int previousSetBit(int i)
removeback to summary
public boolean remove(@Nullable Object o)

Implements java.util.Set.remove.

Doc from java.util.Set.remove.

Removes the specified element from this set if it is present (optional operation). More formally, removes an element e such that Objects.equals(o, e), if this set contains such an element. Returns true if this set contained the element (or equivalently, if this set changed as a result of the call). (This set will not contain the element once the call returns.)

Parameters
o:@Nullable Object

object to be removed from this set, if present

Returns:boolean

true if this set contained the specified element

Annotations
@Override
removeAllback to summary
public boolean removeAll(@NotNull Collection<?> collection)

Implements java.util.Set.removeAll.

Doc from java.util.Set.removeAll.

Removes from this set all of its elements that are contained in the specified collection (optional operation). If the specified collection is also a set, this operation effectively modifies this set so that its value is the asymmetric set difference of the two sets.

Parameters
collection:@NotNull Collection<?>

collection containing elements to be removed from this set

Returns:boolean

true if this set changed as a result of the call

Annotations
@Override
retainAllback to summary
public boolean retainAll(@NotNull Collection<?> collection)

Implements java.util.Set.retainAll.

Doc from java.util.Set.retainAll.

Retains only the elements in this set that are contained in the specified collection (optional operation). In other words, removes from this set all of its elements that are not contained in the specified collection. If the specified collection is also a set, this operation effectively modifies this set so that its value is the intersection of the two sets.

Parameters
collection:@NotNull Collection<?>

collection containing elements to be retained in this set

Returns:boolean

true if this set changed as a result of the call

Annotations
@Override
reversedback to summary
public @NotNull ReversibleIterable<Integer> reversed()

Implements com.vladsch.flexmark.util.collection.iteration.ReversibleIterable.reversed.

Annotations
@Override
@NotNull
reversedIteratorback to summary
public @NotNull ReversibleIterator<Integer> reversedIterator()

Implements com.vladsch.flexmark.util.collection.iteration.ReversibleIterable.reversedIterator.

Annotations
@Override
@NotNull
setback to summary
public @NotNull BitIntegerSet set(int i)
Annotations
@NotNull
setback to summary
public @NotNull BitIntegerSet set(int i, boolean b)
Annotations
@NotNull
setback to summary
public @NotNull BitIntegerSet set(int i, int i1)
Annotations
@NotNull
setback to summary
public @NotNull BitIntegerSet set(int i, int i1, boolean b)
Annotations
@NotNull
sizeback to summary
public int size()

Implements java.util.Set.size.

Doc from java.util.Set.size.

Returns the number of elements in this set (its cardinality). If this set contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of elements in this set (its cardinality)

Annotations
@Override
toArrayback to summary
public @NotNull Object[] toArray()

Implements java.util.Set.toArray.

Doc from java.util.Set.toArray.

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.

The returned array will be "safe" in that no references to it are maintained by this set. (In other words, this method must allocate a new array even if this set is backed by an array). The caller is thus free to modify the returned array.

This method acts as bridge between array-based and collection-based APIs.

Returns:@NotNull Object[]

an array containing all the elements in this set

Annotations
@NotNull
@Override
toArrayback to summary
public <T> T[] toArray(T[] array)

Implements java.util.Set.toArray.

Doc from java.util.Set.toArray.

Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array. If the set fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this set.

If this set fits in the specified array with room to spare (i.e., the array has more elements than this set), the element in the array immediately following the end of the set is set to null. (This is useful in determining the length of this set only if the caller knows that this set does not contain any null elements.)

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.

Like the toArray() method, this method acts as bridge between array-based and collection-based APIs. Further, this method allows precise control over the runtime type of the output array, and may, under certain circumstances, be used to save allocation costs.

Suppose x is a set known to contain only strings. The following code can be used to dump the set into a newly allocated array of String:

    String[] y = x.toArray(new String[0]);
Note that toArray(new Object[0]) is identical in function to toArray().
Parameters
<T>

Doc from java.util.Collection.toArray. the component type of the array to contain the collection

array:T[]

the array into which the elements of this set are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.

Returns:T[]

an array containing all the elements in this set

Annotations
@NotNull
@Override
toArrayback to summary
public @NotNull int[] toArray(@Nullable int[] array)

Implements java.util.Set.toArray.

Doc from java.util.Set.toArray.

Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array. If the set fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this set.

If this set fits in the specified array with room to spare (i.e., the array has more elements than this set), the element in the array immediately following the end of the set is set to null. (This is useful in determining the length of this set only if the caller knows that this set does not contain any null elements.)

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.

Like the toArray() method, this method acts as bridge between array-based and collection-based APIs. Further, this method allows precise control over the runtime type of the output array, and may, under certain circumstances, be used to save allocation costs.

Suppose x is a set known to contain only strings. The following code can be used to dump the set into a newly allocated array of String:

    String[] y = x.toArray(new String[0]);
Note that toArray(new Object[0]) is identical in function to toArray().
Parameters
array:@Nullable int[]

the array into which the elements of this set are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.

Returns:@NotNull int[]

an array containing all the elements in this set

Annotations
@NotNull
toArrayback to summary
public @NotNull int[] toArray(@Nullable int[] array, int destinationIndex)
Annotations
@NotNull
toByteArrayback to summary
public @NotNull byte[] toByteArray()
Annotations
@NotNull
toLongArrayback to summary
public @NotNull long[] toLongArray()
Annotations
@NotNull
valueOfback to summary
public static @NotNull BitIntegerSet valueOf(@NotNull long[] longs)
Annotations
@NotNull
valueOfback to summary
public static @NotNull BitIntegerSet valueOf(@NotNull LongBuffer buffer)
Annotations
@NotNull
valueOfback to summary
public static @NotNull BitIntegerSet valueOf(@NotNull byte[] bytes)
Annotations
@NotNull
valueOfback to summary
public static @NotNull BitIntegerSet valueOf(@NotNull ByteBuffer buffer)
Annotations
@NotNull
xorback to summary
public @NotNull BitIntegerSet xor(@NotNull BitSet set)
Annotations
@NotNull
xorback to summary
public @NotNull BitIntegerSet xor(@NotNull BitIntegerSet set)
Annotations
@NotNull