it.unimi.dsi.bits
Class AbstractBitVector.SubBitVector

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.AbstractBitVector.SubBitVector
All Implemented Interfaces:
BitVector, BigList<Boolean>, BooleanBigList, BooleanCollection, BooleanIterable, BooleanStack, Size64, Stack<Boolean>, Comparable<BigList<? extends Boolean>>, Iterable<Boolean>, Collection<Boolean>, RandomAccess
Enclosing class:
AbstractBitVector

public static class AbstractBitVector.SubBitVector
extends AbstractBitVector
implements BitVector

A subvector of a given bit vector, specified by an initial and a final bit.


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
 
Field Summary
protected  BitVector bitVector
           
protected  long from
           
protected  long to
           
 
Constructor Summary
AbstractBitVector.SubBitVector(BitVector l, long from, long to)
           
 
Method Summary
 void add(int value)
          Adds a bit with specified value at the end of this bit vector.
 void add(long index, boolean value)
          Adds a bit with specified value at the specified index (optional operation).
 void add(long index, int value)
          Adds a bit with specified integer value at the specified index (optional operation).
 BitVector copy(long from, long to)
          Returns a copy of a part of this bit vector.
 boolean getBoolean(long index)
          Returns the value of the specified bit.
 int getInt(long index)
          Returns the value of the specified bit as an integer.
 long getLong(long from, long to)
          Returns the specified bit range as a long.
 long length()
          Returns the number of bits in this bit vector.
 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).
 void set(long index, int value)
          Sets the value of the specified bit as an integer (optional operation).
 long size64()
           
 BitVector subVector(long from, long to)
          Returns a subvector view specified by initial and final index.
 
Methods inherited from class it.unimi.dsi.bits.AbstractBitVector
add, add, and, append, append, asLongBigList, asLongSet, bits, clear, clear, clear, compareTo, compareTo, copy, count, ensureIndex, ensureRestrictedIndex, equals, equals, fast, fill, fill, fill, fill, firstOne, firstZero, flip, flip, flip, flip, getBoolean, hashCode, isPrefix, isProperPrefix, lastOne, lastZero, length, longestCommonPrefixLength, nextOne, nextZero, or, previousOne, previousZero, removeBoolean, replace, set, set, set, size, size, size, subList, 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.bits.BitVector
and, append, append, asLongBigList, asLongSet, bits, clear, copy, count, equals, fast, fill, fill, fill, fill, firstOne, firstZero, flip, flip, flip, hashCode, isPrefix, isProperPrefix, lastOne, lastZero, length, longestCommonPrefixLength, nextOne, nextZero, or, previousOne, previousZero, replace, set, subVector, xor
 
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, size
 
Methods inherited from interface it.unimi.dsi.fastutil.Size64
size
 
Methods inherited from interface it.unimi.dsi.fastutil.booleans.BooleanCollection
add, addAll, booleanIterator, contains, containsAll, rem, removeAll, retainAll, toArray, toArray, toBooleanArray, toBooleanArray
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, isEmpty, remove, removeAll, retainAll, size, toArray
 
Methods inherited from interface java.lang.Comparable
compareTo
 
Methods inherited from interface it.unimi.dsi.fastutil.Stack
isEmpty
 

Field Detail

bitVector

protected final BitVector bitVector

from

protected long from

to

protected long to
Constructor Detail

AbstractBitVector.SubBitVector

public AbstractBitVector.SubBitVector(BitVector l,
                                      long from,
                                      long to)
Method Detail

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.

getInt

public int getInt(long index)
Description copied from interface: BitVector
Returns the value of the specified bit as an integer.

This method is a useful synonym for BitVector.getBoolean(long).

Specified by:
getInt in interface BitVector
Overrides:
getInt in class AbstractBitVector
Parameters:
index - the index of a bit.
Returns:
the value of the specified bit as an integer (0 or 1).

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.

set

public void set(long index,
                int value)
Description copied from interface: BitVector
Sets the value of the specified bit as an integer (optional operation).

This method is a useful synonym for BitVector.set(long, boolean).

Specified by:
set in interface BitVector
Overrides:
set in class AbstractBitVector
Parameters:
index - the index of a bit.
value - the new value (any nonzero integer for setting the bit, zero for clearing the 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.

add

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

This method is a useful synonym for BitVector.add(long, boolean).

Specified by:
add in interface BitVector
Overrides:
add in class AbstractBitVector
Parameters:
index - the index of a bit.
value - the value that will be inserted at position index (any nonzero integer for a true bit, zero for a false bit).

add

public void add(int value)
Description copied from interface: BitVector
Adds a bit with specified value at the end of this bit vector.

This method is a useful synonym for BooleanList.add(boolean).

Specified by:
add in interface BitVector
Overrides:
add in class AbstractBitVector
Parameters:
value - the new value (any nonzero integer for a true bit, zero for a false bit).

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 BitVector 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)

subVector

public BitVector subVector(long from,
                           long to)
Description copied from interface: BitVector
Returns a subvector view specified by initial and final index.

The object returned by this method is a bit vector representing a view of this bit vector restricted to the given indices. Changes to the subvector will be reflected in the main vector.

Specified by:
subVector in interface BitVector
Overrides:
subVector in class AbstractBitVector
Parameters:
from - the first index (inclusive).
to - the last index (not inclusive).

getLong

public long getLong(long from,
                    long to)
Description copied from interface: BitVector
Returns the specified bit range as a long.

Note that bit 0 of the returned long will be bit from of this bit vector.

Implementations are invited to provide high-speed implementations for the case in which from is a multiple of Long.SIZE and to is from + Long.SIZE (or less, in case the vector length is exceeded). This behaviour make it possible to implement high-speed hashing, copies, etc.

Specified by:
getLong in interface BitVector
Overrides:
getLong in class AbstractBitVector
Parameters:
from - the starting bit (inclusive).
to - the ending bit (exclusive).
Returns:
the long value contained in the specified bits.

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.

size64

public long size64()
Specified by:
size64 in interface Size64
Overrides:
size64 in class AbstractBitVector