it.unimi.dsi.bits
Class BooleanListBitVector

java.lang.Object
  extended by java.util.AbstractCollection<Boolean>
      extended by it.unimi.dsi.fastutil.booleans.AbstractBooleanCollection
          extended by it.unimi.dsi.fastutil.booleans.AbstractBooleanBigList
              extended by it.unimi.dsi.bits.AbstractBitVector
                  extended by it.unimi.dsi.bits.BooleanListBitVector
All Implemented Interfaces:
BitVector, BigList<Boolean>, BooleanBigList, BooleanCollection, BooleanIterable, BooleanStack, Size64, Stack<Boolean>, Serializable, Comparable<BigList<? extends Boolean>>, Iterable<Boolean>, Collection<Boolean>, RandomAccess

public class BooleanListBitVector
extends AbstractBitVector
implements Serializable

A boolean-list based implementation of BitVector.

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.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class it.unimi.dsi.bits.AbstractBitVector
AbstractBitVector.LongBigListView, AbstractBitVector.LongSetView, AbstractBitVector.SubBitVector
 
Nested classes/interfaces inherited from class it.unimi.dsi.fastutil.booleans.AbstractBooleanBigList
AbstractBooleanBigList.BooleanSubList
 
Constructor Summary
protected BooleanListBitVector(BooleanBigList list)
           
protected BooleanListBitVector(int capacity)
           
 
Method Summary
 void add(long index, boolean value)
          Adds a bit with specified value at the specified index (optional operation).
 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)
          Returns the value of the specified bit.
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)
          Removes a bit with specified index (optional operation).
 boolean set(long index, boolean value)
          Sets the value of the specified bit (optional operation).
static BooleanListBitVector wrap(BooleanBigList list)
           
static BooleanListBitVector wrap(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, size, size64, subList, subVector, subVector, toString, xor
 
Methods inherited from class it.unimi.dsi.fastutil.booleans.AbstractBooleanBigList
add, addAll, addAll, addAll, addAll, addAll, addAll, addAll, addElements, addElements, contains, get, getElements, indexOf, indexOf, iterator, lastIndexOf, lastIndexOf, listIterator, listIterator, listIterator, peek, peekBoolean, pop, popBoolean, push, push, rem, remove, remove, removeElements, set, subList, top, topBoolean
 
Methods inherited from class it.unimi.dsi.fastutil.booleans.AbstractBooleanCollection
add, booleanIterator, contains, containsAll, containsAll, isEmpty, rem, remove, removeAll, removeAll, retainAll, retainAll, toArray, toArray, 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
addAll, addAll, addAll, addElements, addElements, getElements, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeElements, subList
 
Methods inherited from interface it.unimi.dsi.fastutil.BigList
add, addAll, get, indexOf, lastIndexOf, remove, set
 
Methods inherited from interface it.unimi.dsi.fastutil.booleans.BooleanCollection
addAll, booleanIterator, contains, containsAll, rem, removeAll, retainAll, toArray, toArray, toBooleanArray, toBooleanArray
 
Methods inherited from interface java.util.Collection
add, addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray
 
Methods inherited from interface it.unimi.dsi.fastutil.Stack
isEmpty
 

Constructor Detail

BooleanListBitVector

protected BooleanListBitVector(BooleanBigList list)

BooleanListBitVector

protected BooleanListBitVector(int capacity)
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(BooleanList list)

wrap

public static BooleanListBitVector wrap(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 vector is smaller than or equal to Integer.MAX_VALUE, this method is semantically equivalent to List.size(). In any case, this method is semantically equivalent to Size64.size64().

Specified by:
length in interface BitVector
Returns:
the number of bits in this bit vector.

set

public boolean set(long index,
                   boolean value)
Description copied from interface: BitVector
Sets the value of the specified bit (optional operation).

This method is semantically equivalent to BooleanList.set(int,boolean), but it gives access to long indices.

Specified by:
set in interface BitVector
Specified by:
set in interface BooleanBigList
Overrides:
set in class AbstractBitVector
Parameters:
index - the index of a bit.
value - the new value.

getBoolean

public boolean getBoolean(long index)
Description copied from interface: BitVector
Returns the value of the specified bit.

This method is semantically equivalent to BooleanList.getBoolean(int), but it gives access to long indices.

Specified by:
getBoolean in interface BitVector
Specified by:
getBoolean in interface BooleanBigList
Parameters:
index - the index of a bit.
Returns:
the value of the specified bit.

add

public void add(long index,
                boolean value)
Description copied from interface: BitVector
Adds a bit with specified value at the specified index (optional operation).

This method is semantically equivalent to BooleanList.add(int,boolean), but it gives access to long indices.

Specified by:
add in interface BitVector
Specified by:
add in interface BooleanBigList
Overrides:
add in class AbstractBitVector
Parameters:
index - the index of a bit.
value - the value that will be inserted at position index.

removeBoolean

public boolean removeBoolean(long index)
Description copied from interface: BitVector
Removes a bit with specified index (optional operation).

This method is semantically equivalent to BooleanList.removeBoolean(int), but it gives access to long indices.

Specified by:
removeBoolean in interface BitVector
Specified by:
removeBoolean in interface BooleanBigList
Overrides:
removeBoolean in class AbstractBitVector
Parameters:
index - the index of a bit.
Returns:
the previous value of the bit.

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 interface BitVector
Overrides:
copy in class AbstractBitVector
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 bit to (not inclusive)

copy

public BooleanListBitVector copy()
Description copied from interface: BitVector
Returns a copy of this bit vector.

Specified by:
copy in interface BitVector
Overrides:
copy in class AbstractBitVector
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 number of bits in this vector is smaller than or equal to Integer.MAX_VALUE, this method is semantically equivalent to BooleanList.size(int). In any case, this method is semantically essentially equivalent to BigList.size(long).

Specified by:
length in interface BitVector
Overrides:
length in class AbstractBitVector
Returns:
this bit vector.