org.knime.core.data.vector.bitvector
Class SparseBitVectorCellFactory

java.lang.Object
  extended by org.knime.core.data.vector.bitvector.SparseBitVectorCellFactory

public class SparseBitVectorCellFactory
extends Object

Author:
ohl, University of Konstanz

Constructor Summary
SparseBitVectorCellFactory(long length)
          Initializes the factory to the specified length, all bits cleared.
SparseBitVectorCellFactory(long length, int initialCapacity)
          Initializes the factory to the specified length, all bits cleared.
SparseBitVectorCellFactory(long length, long[] oneIdxs)
          Initializes the factory to the specified length, all bits whose index appear in the passed array are set.
SparseBitVectorCellFactory(SparseBitVector vector)
          A copy of the specified vector is stored in the created bit vector cell.
SparseBitVectorCellFactory(SparseBitVectorCell cell, long startIdx, long endIdx)
          Initializes the vector from a subsequence of the specified cell.
SparseBitVectorCellFactory(String hexString)
          Initializes the created bit vector from the hex representation in the passed string.
 
Method Summary
static SparseBitVectorCell and(BitVectorValue bv1, BitVectorValue bv2)
          Creates a sparse bit vector cell containing the result of the AND operation on the passed operands.
 void clear(long bitIndex)
          Clears the bit with the specified index in the vector.
 SparseBitVectorCell createDataCell()
          Creates a DataCell from the currently stored bit vector.
static SparseBitVectorCell or(BitVectorValue bv1, BitVectorValue bv2)
          Creates a sparse bit vector cell containing the result of the OR operation on the passed operands.
 void set(long bitIndex)
          Sets the bit with the specified index in the vector.
 void set(long bitIdx, boolean value)
          Sets the bit at the specified index to the new value.
static SparseBitVectorCell xor(BitVectorValue bv1, BitVectorValue bv2)
          Creates a sparse bit vector cell containing the result of the XOR operation on the passed operands.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SparseBitVectorCellFactory

public SparseBitVectorCellFactory(long length)
Initializes the factory to the specified length, all bits cleared.

Parameters:
length - of the vector in the cell to create

SparseBitVectorCellFactory

public SparseBitVectorCellFactory(long length,
                                  int initialCapacity)
Initializes the factory to the specified length, all bits cleared. The capacity of the vector (i.e. the storage for the indices of the '1's) is set to the specified value.

Parameters:
length - of the vector in the cell to create
initialCapacity - the number of expected '1's in the vector

SparseBitVectorCellFactory

public SparseBitVectorCellFactory(long length,
                                  long[] oneIdxs)
Initializes the factory to the specified length, all bits whose index appear in the passed array are set.

Parameters:
length - of the vector in the cell to create
oneIdxs - the array containing the indices of the ones. Should be sorted (lowest index first).

SparseBitVectorCellFactory

public SparseBitVectorCellFactory(SparseBitVector vector)
A copy of the specified vector is stored in the created bit vector cell.

Parameters:
vector - used to initialize the bits.

SparseBitVectorCellFactory

public SparseBitVectorCellFactory(SparseBitVectorCell cell,
                                  long startIdx,
                                  long endIdx)
Initializes the vector from a subsequence of the specified cell. The bits used are the ones from startIdx to endIdx - 1. The length of the resulting vector is startIdx - endIdx.

Parameters:
cell - the bit vector cell to take the subsequence from.
startIdx - the first bit to include in the created bit vector
endIdx - the first bit NOT to include in the result vector

SparseBitVectorCellFactory

public SparseBitVectorCellFactory(String hexString)
Initializes the created bit vector from the hex representation in the passed string. Only characters '0' - '9' and 'A' - 'F' are allowed. The character at string position (length - 1) represents the bits with index 0 to 3 in the vector. The character at position 0 represents the bits with the highest indices. The length of the vector created is the length of the string times 4 (as each character represents four bits).

Parameters:
hexString - containing the hex value to initialize the vector with
Throws:
IllegalArgumentException - if hexString contains characters other then the hex characters (i.e. 0 - 9, A - F)
Method Detail

set

public void set(long bitIndex)
Sets the bit with the specified index in the vector.

Parameters:
bitIndex - the index of the bit to set to one.

set

public void set(long bitIdx,
                boolean value)
Sets the bit at the specified index to the new value.

Parameters:
bitIdx - the index of the bit to set or clear
value - if true, the specified bit will be set, otherwise it will be cleared.
Throws:
ArrayIndexOutOfBoundsException - if the index is negative or larger than the size of the vector

clear

public void clear(long bitIndex)
Clears the bit with the specified index in the vector.

Parameters:
bitIndex - the index of the bit to set to zero.

createDataCell

public SparseBitVectorCell createDataCell()
Creates a DataCell from the currently stored bit vector.

Returns:
a DataCell containing the current value of the vector

and

public static SparseBitVectorCell and(BitVectorValue bv1,
                                      BitVectorValue bv2)
Creates a sparse bit vector cell containing the result of the AND operation on the passed operands. The length of the result vector is the maximum of the lengths of the operands.
NOTE: This method performs best if the two arguments are both SparseBitVectorCells. All other implementations need to access the bits through get/set methods which probably performs very poorly.
See also DenseBitVectorCellFactory.and(BitVectorValue, BitVectorValue) for ANDing dense bit vector cells.

Parameters:
bv1 - the first operand to AND with the other
bv2 - the other operand to AND with the first one
Returns:
the result of the AND operation

or

public static SparseBitVectorCell or(BitVectorValue bv1,
                                     BitVectorValue bv2)
Creates a sparse bit vector cell containing the result of the OR operation on the passed operands. The length of the result vector is the maximum of the lengths of the operands.
NOTE: This method performs best if the two arguments are both SparseBitVectorCells. All other implementations need to access the bits through get/set methods which probably performs very poorly.
See also DenseBitVectorCellFactory.and(BitVectorValue, BitVectorValue) for ORing dense bit vector cells.

Parameters:
bv1 - the first operand to OR with the other
bv2 - the other operand to OR with the first one
Returns:
the result of the OR operation

xor

public static SparseBitVectorCell xor(BitVectorValue bv1,
                                      BitVectorValue bv2)
Creates a sparse bit vector cell containing the result of the XOR operation on the passed operands. The length of the result vector is the maximum of the lengths of the operands.
NOTE: This method performs best if the two arguments are both SparseBitVectorCells. All other implementations need to access the bits through get/set methods which probably performs very poorly.
See also DenseBitVectorCellFactory.and(BitVectorValue, BitVectorValue) for XORing dense bit vector cells.

Parameters:
bv1 - the first operand to XOR with the other
bv2 - the other operand to XOR with the first one
Returns:
the result of the XOR operation


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.