public final class BitSets
extends java.lang.Object
BitSet
.Modifier and Type | Class and Description |
---|---|
private static class |
BitSets.Closure
Setup equivalence Sets for each position.
|
Modifier | Constructor and Description |
---|---|
private |
BitSets() |
Modifier and Type | Method and Description |
---|---|
static java.util.SortedMap<java.lang.Integer,java.util.BitSet> |
closure(java.util.SortedMap<java.lang.Integer,java.util.BitSet> equivalence)
Computes the closure of a map from integers to bits.
|
static boolean |
contains(java.util.BitSet set0,
java.util.BitSet set1)
Returns true if all bits set in the second parameter are also set in the
first.
|
static boolean |
contains(java.util.BitSet set0,
ImmutableBitSet set1)
Returns true if all bits set in the second parameter are also set in the
first.
|
static java.util.BitSet |
of(ImmutableIntList bits)
Creates a BitSet with given bits set.
|
static java.util.BitSet |
of(int... bits)
Creates a bitset with given bits set.
|
static java.util.BitSet |
of(java.lang.Integer[] bits)
Creates a BitSet with given bits set.
|
static java.util.BitSet |
of(java.lang.Iterable<? extends java.lang.Number> bits)
Creates a BitSet with given bits set.
|
static void |
populate(java.util.BitSet bitSet,
ImmutableIntList list)
Populates a
BitSet from an
ImmutableIntList . |
static void |
populate(java.util.BitSet bitSet,
java.lang.Iterable<? extends java.lang.Number> list)
Populates a
BitSet from an iterable, such as a list of integer. |
static int |
previousClearBit(java.util.BitSet bitSet,
int fromIndex)
Returns the previous clear bit.
|
static java.util.BitSet |
range(int toIndex)
Creates a BitSet with bits between 0 and
toIndex set. |
static java.util.BitSet |
range(int fromIndex,
int toIndex)
Creates a bitset with bits from
fromIndex (inclusive) to
specified toIndex (exclusive) set to true . |
static void |
setAll(java.util.BitSet bitSet,
java.lang.Iterable<? extends java.lang.Number> list)
Sets all bits in a given BitSet corresponding to integers from a list.
|
static int[] |
toArray(java.util.BitSet bitSet)
Converts a BitSet to an array.
|
static java.lang.Iterable<java.lang.Integer> |
toIter(java.util.BitSet bitSet)
Returns an iterable over the bits in a bitmap that are set to '1'.
|
static java.lang.Iterable<java.lang.Integer> |
toIter(ImmutableBitSet bitSet) |
static java.util.List<java.lang.Integer> |
toList(java.util.BitSet bitSet)
Converts a bitset to a list.
|
static java.util.BitSet |
union(java.util.BitSet set0,
java.util.BitSet... sets)
Returns a BitSet that is the union of the given BitSets.
|
public static boolean contains(java.util.BitSet set0, java.util.BitSet set1)
set0
- Containing bitmapset1
- Bitmap to be checkedpublic static boolean contains(java.util.BitSet set0, ImmutableBitSet set1)
set0
- Containing bitmapset1
- Bitmap to be checkedpublic static java.lang.Iterable<java.lang.Integer> toIter(java.util.BitSet bitSet)
This allows you to iterate over a bit set using a 'foreach' construct. For instance:
BitSet bitSet;
for (int i : Util.toIter(bitSet)) {
print(i);
}
bitSet
- Bit setpublic static java.lang.Iterable<java.lang.Integer> toIter(ImmutableBitSet bitSet)
public static java.util.List<java.lang.Integer> toList(java.util.BitSet bitSet)
The list is mutable, and future changes to the list do not affect the contents of the bit set.
bitSet
- Bit setpublic static int[] toArray(java.util.BitSet bitSet)
bitSet
- Bit setpublic static java.util.BitSet of(int... bits)
For example, of(0, 3)
returns a bit set with bits {0, 3}
set.
bits
- Array of bits to setpublic static java.util.BitSet of(java.lang.Integer[] bits)
For example, of(new Integer[] {0, 3})
returns a bit set
with bits {0, 3} set.
bits
- Array of bits to setpublic static java.util.BitSet of(java.lang.Iterable<? extends java.lang.Number> bits)
For example, of(Arrays.asList(0, 3))
returns a bit set
with bits {0, 3} set.
bits
- Collection of bits to setpublic static java.util.BitSet of(ImmutableIntList bits)
For example, of(ImmutableIntList.of(0, 3))
returns a bit set
with bits {0, 3} set.
bits
- Collection of bits to setpublic static java.util.BitSet range(int fromIndex, int toIndex)
fromIndex
(inclusive) to
specified toIndex
(exclusive) set to true
.
For example, range(0, 3)
returns a bit set with bits
{0, 1, 2} set.
fromIndex
- Index of the first bit to be set.toIndex
- Index after the last bit to be set.public static java.util.BitSet range(int toIndex)
toIndex
set.public static void setAll(java.util.BitSet bitSet, java.lang.Iterable<? extends java.lang.Number> list)
public static java.util.BitSet union(java.util.BitSet set0, java.util.BitSet... sets)
public static int previousClearBit(java.util.BitSet bitSet, int fromIndex)
Has same behavior as BitSet.previousClearBit(int)
, but that method
does not exist before 1.7.
public static java.util.SortedMap<java.lang.Integer,java.util.BitSet> closure(java.util.SortedMap<java.lang.Integer,java.util.BitSet> equivalence)
The input must have an entry for each position.
Does not modify the input map or its bit sets.
public static void populate(java.util.BitSet bitSet, java.lang.Iterable<? extends java.lang.Number> list)
BitSet
from an iterable, such as a list of integer.public static void populate(java.util.BitSet bitSet, ImmutableIntList list)
BitSet
from an
ImmutableIntList
.Copyright © 2012–2019 The Apache Software Foundation. All rights reserved.