Save This Page
Home » mahout-collections-1.0-src » org.apache.mahout.math.bitvector » [javadoc | source]
org.apache.mahout.math.bitvector
public class: BitVector [javadoc | source]
java.lang.Object
   org.apache.mahout.math.PersistentObject
      org.apache.mahout.math.bitvector.BitVector

All Implemented Interfaces:
    Cloneable, Serializable

Deprecated! until - unit tests are in place. Until this time, this class/interface is unsupported.

Constructor:
 public BitVector(int size) 
 public BitVector(long[] bits,
    int size) 
Method from org.apache.mahout.math.bitvector.BitVector Summary:
and,   andNot,   cardinality,   checkSize,   clear,   clear,   clone,   copy,   elements,   elements,   equals,   forEachIndexFromToInState,   get,   getLongFromTo,   getQuick,   hashCode,   indexOfFromTo,   not,   numberOfBitsInPartialUnit,   numberOfFullUnits,   or,   partFromTo,   put,   putLongFromTo,   putQuick,   replaceFromToWith,   replaceFromToWith,   set,   setSize,   size,   toString,   xor
Methods from org.apache.mahout.math.PersistentObject:
clone
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.mahout.math.bitvector.BitVector Detail:
 public  void and(BitVector other) 
      Deprecated!
    Performs a logical AND of the receiver with another bit vector (A = A & B). The receiver is modified so that a bit in it has the value true if and only if it already had the value true and the corresponding bit in the other bit vector argument has the value true.
 public  void andNot(BitVector other) 
      Deprecated!
    Clears all of the bits in receiver whose corresponding bit is set in the other bitvector (A = A \ B). In other words, determines the difference (A=A\B) between two bitvectors.
 public int cardinality() 
      Deprecated!
    Returns the number of bits currently in the true state. Optimized for speed. Particularly quick if the receiver is either sparse or dense.
 protected  void checkSize(BitVector other) 
      Deprecated!
    Sanity check for operations requiring another bitvector with at least the same size.
 public  void clear() 
      Deprecated!
    Clears all bits of the receiver.
 public  void clear(int bitIndex) 
      Deprecated!
    Changes the bit with index bitIndex to the "clear" (false) state.
 public Object clone() 
      Deprecated!
    Cloning this BitVector produces a new BitVector that is equal to it. The clone of the bit vector is another bit vector that has exactly the same bits set to true as this bit vector and the same current size, but independent state.
 public BitVector copy() 
      Deprecated!
    Returns a deep copy of the receiver; calls clone() and casts the result.
 public long[] elements() 
      Deprecated!
    You normally need not use this method. Use this method only if performance is critical. Returns the bit vector's backing bits. WARNING: For efficiency reasons and to keep memory usage low, the array is not copied. So if subsequently you modify the returned array directly via the [] operator, be sure you know what you're doing.

    A bitvector is modelled as a long array, i.e. long[] bits holds bits of a bitvector. Each long value holds 64 bits. The i-th bit is stored in bits[i/64] at bit position i % 64 (where bit position 0 refers to the least significant bit and 63 refers to the most significant bit).

 public  void elements(long[] bits,
    int size) 
      Deprecated!
    You normally need not use this method. Use this method only if performance is critical. Sets the bit vector's backing bits and size. WARNING: For efficiency reasons and to keep memory usage low, the array is not copied. So if subsequently you modify the specified array directly via the [] operator, be sure you know what you're doing.

    A bitvector is modelled as a long array, i.e. long[] bits holds bits of a bitvector. Each long value holds 64 bits. The i-th bit is stored in bits[i/64] at bit position i % 64 (where bit position 0 refers to the least significant bit and 63 refers to the most significant bit).

 public boolean equals(Object obj) 
      Deprecated!
    Compares this object against the specified object. The result is true if and only if the argument is not null and is a BitVector object that has the same size as the receiver and the same bits set to true as the receiver. That is, for every nonnegative int index k,
    ((BitVector)obj).get(k) == this.get(k)
    must be true.
 public boolean forEachIndexFromToInState(int from,
    int to,
    boolean state,
    IntProcedure procedure) 
      Deprecated!
    Applies a procedure to each bit index within the specified range that holds a bit in the given state. Starts at index from, moves rightwards to to. Useful, for example, if you want to copy bits into an image or somewhere else.

    Optimized for speed. Particularly quick if one of the following conditions holds

    • state==true and the receiver is sparse (cardinality() is small compared to size()).
    • state==false and the receiver is dense (cardinality() is large compared to size()).
 public boolean get(int bitIndex) 
      Deprecated!
    Returns from the bitvector the value of the bit with the specified index. The value is true if the bit with the index bitIndex is currently set; otherwise, returns false.
 public long getLongFromTo(int from,
    int to) 
      Deprecated!
    Returns a long value representing bits of the receiver from index from to index to. Bits are returned as a long value with the return value having bit 0 set to bit from, ..., bit to-from set to bit to. All other bits of the return value are set to 0. If to-from+1==0 then returns zero (0L).
 public boolean getQuick(int bitIndex) 
      Deprecated!
    Returns from the bitvector the value of the bit with the specified index; WARNING: Does not check preconditions. The value is true if the bit with the index bitIndex is currently set; otherwise, returns false.

    Provided with invalid parameters this method may return invalid values without throwing any exception. You should only use this method when you are absolutely sure that the index is within bounds. Precondition (unchecked): bitIndex >= 0 && bitIndex < size().

 public int hashCode() 
      Deprecated!
    Returns a hash code value for the receiver. The hash code depends only on which bits have been set within the receiver. The algorithm used to compute it may be described as follows.

    Suppose the bits in the receiver were to be stored in an array of long integers called, say, bits, in such a manner that bit k is set in the receiver (for nonnegative values of k) if and only if the expression

    ((k>>6) < bits.length) && ((bits[k>>6] & (1L << (bit & 0x3F))) != 0)
    is true. Then the following definition of the hashCode method would be a correct implementation of the actual algorithm:
    public int hashCode() {
         long h = 1234;
         for (int i = bits.length; --i >= 0; ) {
              h ^= bits[i] * (i + 1);
         }
         return (int)((h >> 32) ^ h);
    }
    Note that the hash code values change if the set of bits is altered.
 public int indexOfFromTo(int from,
    int to,
    boolean state) 
      Deprecated!
    Returns the index of the first occurrence of the specified state. Returns -1 if the receiver does not contain this state. Searches between from, inclusive and to, inclusive.

    Optimized for speed. Preliminary performance (200Mhz Pentium Pro, JDK 1.2, NT): size=10^6, from=0, to=size-1, receiver contains matching state in the very end --> 0.002 seconds elapsed time.

 public  void not() 
      Deprecated!
    Performs a logical NOT on the bits of the receiver (A = ~A).
 protected int numberOfBitsInPartialUnit() 
      Deprecated!
    Returns the number of bits used in the trailing PARTIAL unit. Returns zero if there is no such trailing partial unit.
 protected int numberOfFullUnits() 
      Deprecated!
    Returns the number of units that are FULL (not PARTIAL).
 public  void or(BitVector other) 
      Deprecated!
    Performs a logical OR of the receiver with another bit vector (A = A | B). The receiver is modified so that a bit in it has the value true if and only if it either already had the value true or the corresponding bit in the other bit vector argument has the value true.
 public BitVector partFromTo(int from,
    int to) 
      Deprecated!
    Constructs and returns a new bit vector which is a copy of the given range. The new bitvector has size()==to-from+1.
 public  void put(int bitIndex,
    boolean value) 
      Deprecated!
    Sets the bit with index bitIndex to the state specified by value.
 public  void putLongFromTo(long value,
    int from,
    int to) 
      Deprecated!
    Sets bits of the receiver from index from to index to to the bits of value. Bit from is set to bit 0 of value, ..., bit to is set to bit to-from of value. All other bits stay unaffected. If to-from+1==0 then does nothing.
 public  void putQuick(int bitIndex,
    boolean value) 
      Deprecated!
    Sets the bit with index bitIndex to the state specified by value; WARNING: Does not check preconditions.

    Provided with invalid parameters this method may set invalid values without throwing any exception. You should only use this method when you are absolutely sure that the index is within bounds. Precondition (unchecked): bitIndex >= 0 && bitIndex < size().

 public  void replaceFromToWith(int from,
    int to,
    boolean value) 
      Deprecated!
    Sets the bits in the given range to the state specified by value.

    Optimized for speed. Preliminary performance (200Mhz Pentium Pro, JDK 1.2, NT): replace 10^6 ill aligned bits --> 0.002 seconds elapsed time.

 public  void replaceFromToWith(int from,
    int to,
    BitVector source,
    int sourceFrom) 
      Deprecated!
    Replaces the bits of the receiver in the given range with the bits of another bit vector. Replaces the range [from,to] with the contents of the range [sourceFrom,sourceFrom+to-from], all inclusive. If source==this and the source and destination range intersect in an ambiguous way, then replaces as if using an intermediate auxiliary copy of the receiver.

    Optimized for speed. Preliminary performance (200Mhz Pentium Pro, JDK 1.2, NT): replace 10^6 ill aligned bits --> 0.02 seconds elapsed time.

 public  void set(int bitIndex) 
      Deprecated!
    Changes the bit with index bitIndex to the "set" (true) state.
 public  void setSize(int newSize) 
      Deprecated!
    Shrinks or expands the receiver so that it holds newSize bits. If the receiver is expanded, additional false bits are added to the end. If the receiver is shrinked, all bits between the old size and the new size are lost; their memory is subject to garbage collection. (This method introduces a new backing array of elements. WARNING: if you have more than one BitVector or BitMatrix sharing identical backing elements, be sure you know what you are doing.)
 public int size() 
      Deprecated!
    Returns the size of the receiver.
 public String toString() 
      Deprecated!
    Returns a string representation of the receiver. For every index for which the receiver contains a bit in the "set" (true) state, the decimal representation of that index is included in the result. Such indeces are listed in order from lowest to highest, separated by ", " (a comma and a space) and surrounded by braces.
 public  void xor(BitVector other) 
      Deprecated!
    Performs a logical XOR of the receiver with another bit vector (A = A ^ B). The receiver is modified so that a bit in it has the value true if and only if one of the following statements holds:
    • The bit initially has the value true, and the corresponding bit in the argument has the value false.
    • The bit initially has the value false, and the corresponding bit in the argument has the value true.