org.knime.core.data.vector.bitvector
Interface BitVectorValue

All Superinterfaces:
DataValue
All Known Implementing Classes:
DenseBitVectorCell, SparseBitVectorCell

public interface BitVectorValue
extends DataValue

Implementing DataCells store '0's and '1's at specific positions in a vector.

Author:
ohl, University of Konstanz

Nested Class Summary
static class BitVectorValue.BitVectorUtilityFactory
          Implementations of the meta information of this value class.
 
Nested classes/interfaces inherited from interface org.knime.core.data.DataValue
DataValue.UtilityFactory
 
Field Summary
static DataValue.UtilityFactory UTILITY
          Meta information to bit vector values.
 
Method Summary
 long cardinality()
          Returns the number of set bits (bits with value '1') in the vector.
 boolean get(long index)
          Returns the value of the specified bit.
 boolean isEmpty()
          Returns true, if all bits in the vector are cleared.
 long length()
          Returns the length of the bit vector.
 long nextClearBit(long startIdx)
          Finds the next bit not set (that is '0') on or after the specified index.
 long nextSetBit(long startIdx)
          Finds the next bit set to one on or after the specified index.
 String toBinaryString()
          Returns the binary string representation of the bits in this vector.
 String toHexString()
          Returns the hex representation of the bits in this vector.
 

Field Detail

UTILITY

static final DataValue.UtilityFactory UTILITY
Meta information to bit vector values.

See Also:
DataValue.UTILITY
Method Detail

length

long length()
Returns the length of the bit vector. The number of stored bits.

Returns:
the number of bits stored in the vector

cardinality

long cardinality()
Returns the number of set bits (bits with value '1') in the vector.

Returns:
the number of set bits (bits with value '1') in the vector.

get

boolean get(long index)
Returns the value of the specified bit.

Parameters:
index - the index of the bit to test
Returns:
true if the bit at the specified index is set, false if it is zero.

isEmpty

boolean isEmpty()
Returns true, if all bits in the vector are cleared.

Returns:
true, if all bits are zero, false, if at least one bit is set.

nextClearBit

long nextClearBit(long startIdx)
Finds the next bit not set (that is '0') on or after the specified index. Returns an index larger than or equal the provided index, or -1 if no bit is cleared after the startIdx. (It is okay to pass an index larger than the length of the vector.)

Parameters:
startIdx - the first index to look for '0's.
Returns:
the index of the next cleared bit, which is on or after the provided startIdx. Or -1 if the vector contains no zero anymore.
Throws:
ArrayIndexOutOfBoundsException - if the specified startIdx negative

nextSetBit

long nextSetBit(long startIdx)
Finds the next bit set to one on or after the specified index. Returns an index larger than or equal the provided index, or -1 if no bit is set after the startIdx. (Is okay to pass an index larger than the length of the vector.)

Parameters:
startIdx - the first index to look for '1's. (It is allowed to pass an index larger then the vector's length.)
Returns:
the index of the next bit set to one, which is on or after the provided startIdx.
Throws:
ArrayIndexOutOfBoundsException - if the specified startIdx is negative

toHexString

String toHexString()
Returns the hex representation of the bits in this vector. Each character in the result represents 4 bits (with the characters '0' - '9' and 'A' - 'F'). The character at string position (length - 1) holds the lowest bits (bit 0 to 3), the character at position 0 represents the bits with the largest index in the vector. If the length of the vector is larger than (Integer.MAX_VALUE - 1) * 4 (i.e. 8589934584), the result is truncated (and ends with ...).

Returns:
the hex representation of this bit vector.

toBinaryString

String toBinaryString()
Returns the binary string representation of the bits in this vector. Each character in the result represents one bit - a '1' stands for a set bit, a '0' represents a cleared bit. The character at string position (length - 1) holds the bit with index 0, the character at position 0 represents the bits with the largest index in the vector. If the length of the vector is larger than (Integer.MAX_VALUE - 3) (i.e. 2147483644), the result is truncated (and ends with ...).

Returns:
the binary (0/1) representation of this bit vector.


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.