This class represents a bitset, with each element either 1 or 0.
A bitset is similar conceptually to a Python dictionary that contains
keys that are integers from 1 to the length of the bitset, and the value
for each key is an on/off boolean (1 or 0).
Bitsets are usually used when keeping track of which atoms in the ct
an operation needs to be performed on; in which case the length of the
Bitset is the number of atoms in the ct.
An instance of Bitset can be converted to a list containing the
elements that are on (i.e. set to 1) via list(bitset) and to a set via
set(bitset).
This is an object-oriented wrapper for the underlying MMBS library.
All state is stored in the C library. References to instances of this
class can be used in direct mmbs library calls, as it will converted to
the integer handle when necessary.
|
__init__(self,
handle=None,
manage_handle=True,
error_handler=None,
size=None)
Initialize an object with an existing MMBS handle or a size. |
|
|
|
_delete(self)
A function to terminate this object. |
|
|
|
size(self)
Return the capacity (i.e. |
|
|
|
resize(self,
size)
Modify the capacity of the Bitset. |
|
|
|
count(self)
Return the number of index values that are set to 'on'. |
|
|
|
get(self,
index)
Get the value of the index. |
|
|
|
set(self,
index)
Set the index value to 'on'. |
|
|
|
unset(self,
index)
Set the index value to 'off'. |
|
|
|
bsand(self,
other)
Return a Bitset of items that are both ON in this set and ON in the
<other> set. |
|
|
|
range(self,
start,
finish)
Set all bits in a range from "start" to "finish" |
|
|
|
fill(self)
Set all bits to on. |
|
|
|
__repr__(self)
Return a Python representation string for this bitset. |
|
|
|
__str__(self)
Return a string of this bitset. |
|
|
|
__iter__(self)
Return an iterator for this bitset. |
|
|
|
__len__(self)
Returns the size of the bitset (Number of ON and OFF bits) |
|
|
|
getOffIterator(self)
Allows looping over all of the OFF bits |
|
|
Inherited from mmobject.MmObject :
__del__ ,
__int__
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__setattr__ ,
__sizeof__ ,
__subclasshook__
|