Package DataStructs :: Module cDataStructs :: Class SparseBitVect
[hide private]
[frames] | no frames]

Class SparseBitVect



 object --+    
          |    
??.instance --+
              |
             SparseBitVect

A class to store sparse bit vectors.

This class is most useful for situations where the size of the vector
is large and relatively few bits are set

For smaller or denser vectors, the _ExplicitBitVect_ class is much faster.

As you would expect, _SparseBitVects_ support a set of binary operations
so you can do things like:
  bv3 = bv1 & bv2  (bitwise and)
  bv3 = bv1 | bv2  (bitwise or)
  bv3 = bv1 ^ bv2  (bitwise xor)
  bv3 = ~bv1       (bitwise negation) NOTE: this operation is likely
                    to be VERY slow and inefficient.

Bits can be set and read using either the Set/UnsetBit() and GetBit() methods
or by indexing (i.e. bv[i] = 1 or if bv[i]).



Instance Methods [hide private]
 
FromBase64(...)
Initializes the vector from a base64 string (the Daylight encoding).
 
GetBit(...)
Returns the value of a bit.
 
GetNumBits(...)
Returns the number of bits in the vector (the vector's size).
 
GetNumOffBits(...)
Returns the number of off bits.
 
GetNumOnBits(...)
Returns the number of on bits.
 
GetOnBits(...)
Returns a tuple containing IDs of the on bits.
 
SetBit(...)
Turns on a particular bit on.
 
SetBitsFromList(...)
Turns on a set of bits.
 
ToBase64(...)
Converts the vector to a base64 string (the Daylight encoding).
 
ToBinary(...)
Returns a binary string representation of the vector.
 
ToBitString(...)
C++ signature: BitVectToText(SparseBitVect) -> std::string Returns a string of zeros and ones representing the bit vector.
source code
 
UnSetBit(...)
Turns on a particular bit off.
 
__and__(...)
C++ signature:...
 
__getinitargs__(...)
C++ signature:...
 
__getitem__(...)
C++ signature:...
 
__init__(...)
C++ signature:...
 
__invert__(...)
C++ signature:...
 
__len__(...)
C++ signature:...
 
__or__(...)
C++ signature:...
 
__reduce__(...)
helper for pickle
 
__setitem__(...)
C++ signature:...
 
__xor__(...)
C++ signature:...

Inherited from unreachable.instance: __new__

Inherited from object: __delattr__, __getattribute__, __hash__, __reduce_ex__, __repr__, __setattr__, __str__

Class Variables [hide private]
  __instance_size__ = 20
  __safe_for_unpickling__ = True
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

FromBase64(...)

 
Initializes the vector from a base64 string (the Daylight encoding).

C++ signature:
    FromBase64(SparseBitVect {lvalue}, std::string) -> void*

GetBit(...)

 
Returns the value of a bit.

C++ signature:
    GetBit(SparseBitVect {lvalue}, unsigned int) -> bool

GetNumBits(...)

 
Returns the number of bits in the vector (the vector's size).

C++ signature:
    GetNumBits(SparseBitVect {lvalue}) -> unsigned int

GetNumOffBits(...)

 
Returns the number of off bits.

C++ signature:
    GetNumOffBits(SparseBitVect {lvalue}) -> unsigned int

GetNumOnBits(...)

 
Returns the number of on bits.

C++ signature:
    GetNumOnBits(SparseBitVect {lvalue}) -> unsigned int

GetOnBits(...)

 
Returns a tuple containing IDs of the on bits.

C++ signature:
    GetOnBits(SparseBitVect) -> std::vector<int, std::allocator<int> >

SetBit(...)

 
Turns on a particular bit on.  Returns the original state of the bit.

C++ signature:
    SetBit(SparseBitVect {lvalue}, unsigned int) -> bool

SetBitsFromList(...)

 
Turns on a set of bits.  The argument should be a tuple or list of bit ids.

C++ signature:
    SetBitsFromList(SparseBitVect*, boost::python::api::object) -> void*

ToBase64(...)

 
Converts the vector to a base64 string (the Daylight encoding).

C++ signature:
    ToBase64(SparseBitVect {lvalue}) -> std::string

ToBinary(...)

 
Returns a binary string representation of the vector.

C++ signature:
    ToBinary(SparseBitVect {lvalue}) -> std::string

ToBitString(...)

source code 
C++ signature:
    BitVectToText(SparseBitVect) -> std::string

Returns a string of zeros and ones representing the bit vector.
C++ signature:
    BitVectToText(ExplicitBitVect) -> std::string

UnSetBit(...)

 
Turns on a particular bit off.  Returns the original state of the bit.

C++ signature:
    UnSetBit(SparseBitVect {lvalue}, unsigned int) -> bool

__and__(...)
(And operator)

 
C++ signature:
__and__(SparseBitVect {lvalue}, SparseBitVect) -> _object*

__getinitargs__(...)

 
C++ signature:
__getinitargs__(SparseBitVect) -> boost::python::tuple

__getitem__(...)
(Indexing operator)

 
C++ signature:
__getitem__(SparseBitVect, unsigned int) -> int

__init__(...)
(Constructor)

 
C++ signature:
    __init__(_object*, unsigned int) -> void*
C++ signature:
    __init__(_object*, std::string) -> void*

Overrides: object.__init__

__invert__(...)

 
C++ signature:
__invert__(SparseBitVect {lvalue}) -> _object*

__len__(...)
(Length operator)

 
C++ signature:
__len__(SparseBitVect {lvalue}) -> unsigned int

__or__(...)
(Or operator)

 
C++ signature:
__or__(SparseBitVect {lvalue}, SparseBitVect) -> _object*

__reduce__(...)

 
helper for pickle

Overrides: object.__reduce__
(inherited documentation)

__setitem__(...)
(Index assignment operator)

 
C++ signature:
__setitem__(SparseBitVect {lvalue}, unsigned int, int) -> int

__xor__(...)

 
C++ signature:
__xor__(SparseBitVect {lvalue}, SparseBitVect) -> _object*