Package it.unimi.dsi.bits
Class BooleanListBitVector
- java.lang.Object
-
- java.util.AbstractCollection<java.lang.Boolean>
-
- it.unimi.dsi.fastutil.booleans.AbstractBooleanCollection
-
- it.unimi.dsi.fastutil.booleans.AbstractBooleanBigList
-
- it.unimi.dsi.bits.AbstractBitVector
-
- it.unimi.dsi.bits.BooleanListBitVector
-
- All Implemented Interfaces:
BitVector
,it.unimi.dsi.fastutil.BigList<java.lang.Boolean>
,it.unimi.dsi.fastutil.booleans.BooleanBigList
,it.unimi.dsi.fastutil.booleans.BooleanCollection
,it.unimi.dsi.fastutil.booleans.BooleanIterable
,it.unimi.dsi.fastutil.booleans.BooleanStack
,it.unimi.dsi.fastutil.Size64
,it.unimi.dsi.fastutil.Stack<java.lang.Boolean>
,java.io.Serializable
,java.lang.Comparable<it.unimi.dsi.fastutil.BigList<? extends java.lang.Boolean>>
,java.lang.Iterable<java.lang.Boolean>
,java.util.Collection<java.lang.Boolean>
,java.util.RandomAccess
public class BooleanListBitVector extends AbstractBitVector implements java.io.Serializable
A boolean-list based implementation ofBitVector
.- See Also:
- Serialized Form
- Implementation Notes:
- This implementation of a bit vector is based on a backing list of booleans. It is
rather inefficient, but useful for wrapping purposes, for covering completely the code
in
AbstractBitVector
and for creating mock objects.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class it.unimi.dsi.bits.AbstractBitVector
AbstractBitVector.LongBigListView, AbstractBitVector.LongSetView, AbstractBitVector.SubBitVector
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BooleanListBitVector(int capacity)
protected
BooleanListBitVector(it.unimi.dsi.fastutil.booleans.BooleanBigList list)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(long index, boolean value)
BooleanListBitVector
copy()
Returns a copy of this bit vector.BooleanListBitVector
copy(long from, long to)
Returns a copy of a part of this bit vector.BitVector
ensureCapacity(long numBits)
protected static void
ensureIntegerIndex(long index)
boolean
getBoolean(long index)
static BooleanListBitVector
getInstance()
Creates a new empty bit vector.static BooleanListBitVector
getInstance(long capacity)
long
length()
Returns the number of bits in this bit vector.BitVector
length(long numBits)
Sets the number of bits in this bit vector.static BooleanListBitVector
of(int... bit)
Creates a new bit vector with given bits.boolean
removeBoolean(long index)
boolean
set(long index, boolean value)
static BooleanListBitVector
wrap(it.unimi.dsi.fastutil.booleans.BooleanBigList list)
static BooleanListBitVector
wrap(it.unimi.dsi.fastutil.booleans.BooleanList list)
-
Methods inherited from class it.unimi.dsi.bits.AbstractBitVector
add, add, add, add, and, append, append, asLongBigList, asLongSet, bits, clear, clear, clear, compareTo, compareTo, count, ensureIndex, ensureRestrictedIndex, equals, equals, fast, fill, fill, fill, fill, firstOne, firstZero, flip, flip, flip, flip, getBoolean, getInt, getLong, hashCode, isPrefix, isProperPrefix, lastOne, lastZero, longestCommonPrefixLength, nextOne, nextZero, or, previousOne, previousZero, removeBoolean, replace, set, set, set, set, size, size, size64, subVector, subVector, toString, xor
-
Methods inherited from class it.unimi.dsi.fastutil.booleans.AbstractBooleanBigList
add, addAll, addAll, addAll, addAll, addElements, addElements, contains, forEach, get, getElements, indexOf, indexOf, iterator, lastIndexOf, lastIndexOf, listIterator, listIterator, peek, peekBoolean, pop, popBoolean, push, push, rem, remove, removeElements, set, setElements, subList, top, topBoolean
-
Methods inherited from class it.unimi.dsi.fastutil.booleans.AbstractBooleanCollection
add, contains, containsAll, containsAll, remove, removeAll, removeAll, retainAll, retainAll, toArray, toBooleanArray, toBooleanArray
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface it.unimi.dsi.fastutil.booleans.BooleanBigList
add, addAll, addAll, addAll, addAll, addAll, addElements, addElements, get, getElements, getElements, indexOf, indexOf, iterator, lastIndexOf, lastIndexOf, listIterator, listIterator, remove, removeElements, set, setElements, setElements, setElements, spliterator, subList
-
Methods inherited from interface it.unimi.dsi.fastutil.booleans.BooleanCollection
add, addAll, contains, contains, containsAll, rem, remove, removeAll, removeIf, removeIf, retainAll, toArray, toBooleanArray, toBooleanArray
-
-
-
-
Method Detail
-
ensureIntegerIndex
protected static final void ensureIntegerIndex(long index)
-
getInstance
public static BooleanListBitVector getInstance(long capacity)
-
getInstance
public static BooleanListBitVector getInstance()
Creates a new empty bit vector.
-
of
public static BooleanListBitVector of(int... bit)
Creates a new bit vector with given bits.
-
wrap
public static BooleanListBitVector wrap(it.unimi.dsi.fastutil.booleans.BooleanList list)
-
wrap
public static BooleanListBitVector wrap(it.unimi.dsi.fastutil.booleans.BooleanBigList list)
-
length
public long length()
Description copied from interface:BitVector
Returns the number of bits in this bit vector.If the number of bits in this bit vector is smaller than or equal to
Integer.MAX_VALUE
, this method is semantically equivalent toList.size()
. In any case, this method is semantically equivalent toSize64.size64()
, but it is prefererred.
-
set
public boolean set(long index, boolean value)
- Specified by:
set
in interfaceit.unimi.dsi.fastutil.booleans.BooleanBigList
- Overrides:
set
in classAbstractBitVector
-
getBoolean
public boolean getBoolean(long index)
- Specified by:
getBoolean
in interfaceit.unimi.dsi.fastutil.booleans.BooleanBigList
-
add
public void add(long index, boolean value)
- Specified by:
add
in interfaceit.unimi.dsi.fastutil.booleans.BooleanBigList
- Overrides:
add
in classAbstractBitVector
-
removeBoolean
public boolean removeBoolean(long index)
- Specified by:
removeBoolean
in interfaceit.unimi.dsi.fastutil.booleans.BooleanBigList
- Overrides:
removeBoolean
in classAbstractBitVector
-
copy
public BooleanListBitVector copy(long from, long to)
Description copied from interface:BitVector
Returns a copy of a part of this bit vector.- Specified by:
copy
in interfaceBitVector
- Overrides:
copy
in classAbstractBitVector
- Parameters:
from
- the starting bit, inclusive.to
- the ending bit, not inclusive.- Returns:
- a copy of the part of this bit vector going from bit
from
(inclusive) to bitto
(not inclusive)
-
copy
public BooleanListBitVector copy()
Description copied from interface:BitVector
Returns a copy of this bit vector.- Specified by:
copy
in interfaceBitVector
- Overrides:
copy
in classAbstractBitVector
- Returns:
- a copy of this bit vector.
-
ensureCapacity
public BitVector ensureCapacity(long numBits)
-
length
public BitVector length(long numBits)
Description copied from interface:BitVector
Sets the number of bits in this bit vector.It is expected that this method will try to allocate exactly the necessary space.
If the argument fits an integer, this method has the same side effects of
BooleanList.size(int)
. In any case, this method has the same side effects ofBigList.size(long)
, but it is preferred, as it has the advantage of returning this bit vector, thus making it possible to chain methods.- Specified by:
length
in interfaceBitVector
- Overrides:
length
in classAbstractBitVector
- Parameters:
numBits
- the new length in bits for this bit vector.- Returns:
- this bit vector.
-
-