com.bigdata.util
Class ByteBufferBitVector

java.lang.Object
  extended by it.unimi.dsi.fastutil.booleans.AbstractBooleanCollection
      extended by it.unimi.dsi.fastutil.booleans.AbstractBooleanList
          extended by it.unimi.dsi.bits.AbstractBitVector
              extended by com.bigdata.util.ByteBufferBitVector
All Implemented Interfaces:
it.unimi.dsi.bits.BitVector, it.unimi.dsi.fastutil.booleans.BooleanCollection, it.unimi.dsi.fastutil.booleans.BooleanIterable, it.unimi.dsi.fastutil.booleans.BooleanList, it.unimi.dsi.fastutil.booleans.BooleanStack, it.unimi.dsi.fastutil.Stack<Boolean>, Comparable<List<? extends Boolean>>, Iterable<Boolean>, Collection<Boolean>, List<Boolean>, RandomAccess

public class ByteBufferBitVector
extends it.unimi.dsi.bits.AbstractBitVector

Wraps a ByteBuffer as a read-only BitVector.

Version:
$Id: ByteBufferBitVector.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson

Nested Class Summary
 
Nested classes/interfaces inherited from class it.unimi.dsi.bits.AbstractBitVector
it.unimi.dsi.bits.AbstractBitVector.LongBigListView, it.unimi.dsi.bits.AbstractBitVector.LongSetView, it.unimi.dsi.bits.AbstractBitVector.SubBitVector
 
Nested classes/interfaces inherited from class it.unimi.dsi.fastutil.booleans.AbstractBooleanList
it.unimi.dsi.fastutil.booleans.AbstractBooleanList.BooleanSubList
 
Constructor Summary
ByteBufferBitVector(ByteBuffer b)
          Ctor assumes that all bits in the buffer are used.
ByteBufferBitVector(ByteBuffer b, long off, long len)
           
 
Method Summary
protected  int byteIndexForBit(long bitIndex)
          Return the index of the byte in which the bit with the given index is encoded.
 boolean getBoolean(long index)
          Extract and return a bit coded flag.
 long length()
           
protected  int withinByteIndexForBit(long bitIndex)
          Return the offset within the byte in which the bit is coded of the bit (this is just the remainder bitIndex % 8).
 
Methods inherited from class it.unimi.dsi.bits.AbstractBitVector
add, add, add, add, add, and, append, append, asLongBigList, asLongSet, bits, clear, clear, clear, compareTo, compareTo, copy, copy, count, ensureIndex, ensureRestrictedIndex, equals, fast, fill, fill, fill, fill, firstOne, firstZero, flip, flip, flip, flip, getBoolean, getInt, getLong, hashCode, lastOne, lastZero, length, longestCommonPrefixLength, nextOne, nextZero, or, previousOne, previousZero, removeBoolean, removeBoolean, replace, set, set, set, set, set, size, size, subList, subVector, subVector, toString, xor
 
Methods inherited from class it.unimi.dsi.fastutil.booleans.AbstractBooleanList
add, addAll, addAll, addAll, addAll, addAll, addAll, addElements, addElements, booleanListIterator, booleanListIterator, booleanSubList, contains, ensureIndex, ensureRestrictedIndex, get, getElements, indexOf, indexOf, iterator, lastIndexOf, lastIndexOf, listIterator, listIterator, peek, peekBoolean, pop, popBoolean, push, push, rem, remove, remove, removeElements, set, top, topBoolean
 
Methods inherited from class it.unimi.dsi.fastutil.booleans.AbstractBooleanCollection
add, booleanIterator, contains, containsAll, containsAll, isEmpty, rem, 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.BooleanList
addAll, addAll, addAll, addElements, addElements, booleanListIterator, booleanListIterator, booleanSubList, getElements, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeElements
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, contains, containsAll, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeAll, retainAll, set, toArray, toArray
 
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 it.unimi.dsi.fastutil.Stack
isEmpty
 

Constructor Detail

ByteBufferBitVector

public ByteBufferBitVector(ByteBuffer b)
Ctor assumes that all bits in the buffer are used.

Parameters:
b - The buffer.

ByteBufferBitVector

public ByteBufferBitVector(ByteBuffer b,
                           long off,
                           long len)
Parameters:
b - The buffer.
off - The offset from the start of the buffer for the view.
len - The #of bits which will be included in the view.
Method Detail

length

public final long length()

byteIndexForBit

protected final int byteIndexForBit(long bitIndex)
Return the index of the byte in which the bit with the given index is encoded.

Parameters:
bitIndex - The bit index.
Returns:
The byte index.

withinByteIndexForBit

protected final int withinByteIndexForBit(long bitIndex)
Return the offset within the byte in which the bit is coded of the bit (this is just the remainder bitIndex % 8).

Parameters:
bitIndex - The bit index into the byte[].
Returns:
The offset of the bit in the appropriate byte.

getBoolean

public boolean getBoolean(long index)
Extract and return a bit coded flag.

Parameters:
offset - The offset in the buffer of the start of the byte[] sequence in which the bit coded flags are stored.
index - The index of the bit.
Returns:
The value of the bit.


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.