![]() |
Chemical Data Processing Library Python API - Version 1.4.0
|
Data structure for the storage and processing of variably sized bit sets. More...
Inheritance diagram for CDPL.Util.BitSet:Public Member Functions | |
| None | __init__ () |
Constructs a BitSet instance of size zero. | |
| None | __init__ (BitSet bs) |
Contructs a copy of the BitSet instance bs. More... | |
| None | __init__ (int num_bits, int value=0) |
Constructs a BitSet instance of size num_bits initialized to the bits in value. More... | |
| None | __init__ (str bit_str) |
Constructs a BitSet instance with size and bit values specified by the string bit_str. More... | |
| int | getObjectID () |
| Returns the numeric identifier (ID) of the wrapped C++ class instance. More... | |
| None | swap (BitSet bs) |
| Swaps the contents of this bitset and the bitset bs. More... | |
| BitSet | assign (BitSet bs) |
Replaces the current state with a copy of the state of the BitSet instance bs. More... | |
| None | resize (int num_bits, bool value=False) |
| Changes the number of bits to num_bits. More... | |
| None | clear () |
| Resizes the bitset to zero length. | |
| None | append (bool value) |
| Increases the size of the bitset by one, and sets the value of the new most significant bit to value. More... | |
| BitSet | flip () |
| Toggles the value of every bit. More... | |
| BitSet | flip (int idx) |
| Toggles the value of the bit at index idx. More... | |
| BitSet | set () |
Sets all bits to True. More... | |
| BitSet | set (int idx, bool value=True) |
| Sets the bit at index idx to value. More... | |
| BitSet | reset () |
Sets all bits to False. More... | |
| BitSet | reset (int idx) |
Sets the bit at index idx to False. More... | |
| bool | test (int idx) |
| Returns the value of the bit at index idx. More... | |
| int | findFirst () |
| Returns the index of the first set bit (if any). More... | |
| int | findNext (int idx) |
| Returns the index of the first set bit after idx (if any). More... | |
| bool | isSubsetOf (BitSet bs) |
| Checks whether this bitset is a subset of the bitset bs. More... | |
| bool | isProperSubsetOf (BitSet bs) |
| Checks whether this bitset is a proper subset of the bitset bs. More... | |
| bool | isEmpty () |
| Checks whether this bitset has size zero. More... | |
| int | getCount () |
| Returns the number of set bits. More... | |
| int | getSize () |
| Returns the size of the bitset. More... | |
| int | getMaxSize () |
| Returns the maximum allowed bitset size. More... | |
| bool | hasAny () |
| Checks whether at least one bit is set. More... | |
| bool | hasNone () |
| Checks whether all bits are unset. More... | |
| bool | __getitem__ (int idx) |
| Returns the value of the bit at index idx. More... | |
| None | __setitem__ (int idx, bool value) |
| Sets the bit at index idx to value. More... | |
| BitSet | __and__ (BitSet bs) |
| Performs a bitwise‐AND of this bitset and the bitset bs. More... | |
| BitSet | __or__ (BitSet bs) |
| Performs a bitwise‐OR of this bitset and the bitset bs. More... | |
| BitSet | __xor__ (BitSet bs) |
| Performs a bitwise‐XOR of this bitset and the bitset bs. More... | |
| BitSet | __sub__ (BitSet bs) |
| Computes the set difference of this bitset and the bitset bs. More... | |
| BitSet | __iand__ (BitSet bs) |
| Performs an in-place bitwise‐AND of this bitset and the bitset bs. More... | |
| BitSet | __ior__ (BitSet bs) |
| Performs an in-place bitwise‐OR of this bitset and the bitset bs. More... | |
| BitSet | __ixor__ (BitSet bs) |
| Performs an in-place bitwise‐XOR of this bitset and the bitset bs. More... | |
| BitSet | __isub__ (BitSet bs) |
| Computes the in-place set difference of this bitset and the bitset bs. More... | |
| int | __long__ () |
| Returns the numeric value that corresponds to this bitset (0 if empty). More... | |
| BitSet | __ilshift__ (int num_bits) |
| Shifts the bits to the left by num_bits positions. More... | |
| BitSet | __lshift__ (int num_bits) |
| Shifts the bits in a copy of this bitset to the left by num_bits positions. More... | |
| BitSet | __irshift__ (int num_bits) |
| Shifts the bits to the right by num_bits positions. More... | |
| BitSet | __rshift__ (int num_bits) |
| Shifts the bits in a copy of this bitset to the right by num_bits positions. More... | |
| BitSet | __invert__ () |
| Toggles the value of every bit. More... | |
| bool | __eq__ (BitSet bs) |
| Checks whether this bitset is equal to the bitset bs. More... | |
| bool | __ne__ (BitSet bs) |
| Checks whether this bitset is not equal to the bitset bs. More... | |
| bool | __lt__ (BitSet bs) |
| Checks whether this bitset is lexicographically less than the bitset bs. More... | |
| bool | __le__ (BitSet bs) |
| Checks whether this bitset is lexicographically less or equal to the bitset bs. More... | |
| bool | __gt__ (BitSet bs) |
| Checks whether this bitset is lexicographically greater than the bitset bs. More... | |
| bool | __ge__ (BitSet bs) |
| Checks whether this bitset is lexicographically greater or equal to the bitset bs. More... | |
| int | __len__ () |
| Returns the size of the bitset. More... | |
| bool | __nonzero__ () |
| Checks whether at least one bit is set. More... | |
| bool | __bool__ () |
| Checks whether at least one bit is set. More... | |
| str | __str__ () |
Returns a string representation of the BitSet instance. More... | |
Static Public Attributes | |
| int | npos = 18446744073709551615 |
| Specifies an invalid bit index. | |
Properties | |
| objectID = property(getObjectID) | |
| empty = property(isEmpty) | |
| count = property(getCount) | |
| size = property(getSize) | |
| maxSize = property(getMaxSize) | |
| any = property(hasAny) | |
| none = property(hasNone) | |
Data structure for the storage and processing of variably sized bit sets.
For further information see [BDBS].
| None CDPL.Util.BitSet.__init__ | ( | BitSet | bs | ) |
| None CDPL.Util.BitSet.__init__ | ( | int | num_bits, |
| int | value = 0 |
||
| ) |
Constructs a BitSet instance of size num_bits initialized to the bits in value.
The first M bits (where M is the number of bits of the data type unsigned long) are initialized to the corresponding bits in value and all other bits, if any, to zero.
| num_bits | The size of the bitset. |
| value | The value to initialize the bitset from. |
| None CDPL.Util.BitSet.__init__ | ( | str | bit_str | ) |
Constructs a BitSet instance with size and bit values specified by the string bit_str.
The value of bit i is specified by the character '1' (= on) or '0' (= off) at index i of bit_str.
| bit_str | The string specifying the desired bit values. |
| int CDPL.Util.BitSet.getObjectID | ( | ) |
Returns the numeric identifier (ID) of the wrapped C++ class instance.
Different Python BitSet instances may reference the same underlying C++ class instance. The commonly used Python expression a is not b thus cannot tell reliably whether the two BitSet instances a and b reference different C++ objects. The numeric identifier returned by this method allows to correctly implement such an identity test via the simple expression a.getObjectID() != b.getObjectID().
| None CDPL.Util.BitSet.swap | ( | BitSet | bs | ) |
Swaps the contents of this bitset and the bitset bs.
| bs | The other BitSet instance. |
| None CDPL.Util.BitSet.resize | ( | int | num_bits, |
| bool | value = False |
||
| ) |
Changes the number of bits to num_bits.
| num_bits | The new size of the bitset. |
| value | The value of emerging new bits. |
| None CDPL.Util.BitSet.append | ( | bool | value | ) |
Increases the size of the bitset by one, and sets the value of the new most significant bit to value.
| value | The value of the new bit. |
| BitSet CDPL.Util.BitSet.flip | ( | ) |
Toggles the value of every bit.
| BitSet CDPL.Util.BitSet.flip | ( | int | idx | ) |
Toggles the value of the bit at index idx.
| idx | The zero-based index of the bit. |
| Base.IndexError | if idx is not in the range [0, getSize()). |
| BitSet CDPL.Util.BitSet.set | ( | ) |
Sets all bits to True.
| BitSet CDPL.Util.BitSet.set | ( | int | idx, |
| bool | value = True |
||
| ) |
Sets the bit at index idx to value.
| idx | The zero-based index of the bit. |
| value | The new value of the bit. |
| Base.IndexError | if idx is not in the range [0, getSize()). |
| BitSet CDPL.Util.BitSet.reset | ( | ) |
Sets all bits to False.
| BitSet CDPL.Util.BitSet.reset | ( | int | idx | ) |
Sets the bit at index idx to False.
| idx | The zero-based index of the bit. |
| Base.IndexError | if idx is not in the range [0, getSize()). |
| bool CDPL.Util.BitSet.test | ( | int | idx | ) |
Returns the value of the bit at index idx.
| idx | The zero-based index of the bit. |
| Base.IndexError | if idx is not in the range [0, getSize()). |
| int CDPL.Util.BitSet.findFirst | ( | ) |
Returns the index of the first set bit (if any).
| int CDPL.Util.BitSet.findNext | ( | int | idx | ) |
Returns the index of the first set bit after idx (if any).
| Base.IndexError | if idx is not in the range [0, getSize()). |
| bool CDPL.Util.BitSet.isSubsetOf | ( | BitSet | bs | ) |
Checks whether this bitset is a subset of the bitset bs.
| bs | The other BitSet instance. |
True if for every bit that is set in this bitset the corresponding bit in bs is also set, and False otherwise. | bool CDPL.Util.BitSet.isProperSubsetOf | ( | BitSet | bs | ) |
Checks whether this bitset is a proper subset of the bitset bs.
| bs | The other BitSet instance. |
True if for every bit that is set in this bitset the corresponding bit in bs is also set and furthermore getCount() < bs.getCount(). Otherwise False is returned. | bool CDPL.Util.BitSet.isEmpty | ( | ) |
Checks whether this bitset has size zero.
True if the size is zero, and False otherwise. | int CDPL.Util.BitSet.getCount | ( | ) |
Returns the number of set bits.
| int CDPL.Util.BitSet.getSize | ( | ) |
Returns the size of the bitset.
| int CDPL.Util.BitSet.getMaxSize | ( | ) |
Returns the maximum allowed bitset size.
| bool CDPL.Util.BitSet.hasAny | ( | ) |
Checks whether at least one bit is set.
True if at least one bit is set, and False otherwise. | bool CDPL.Util.BitSet.hasNone | ( | ) |
Checks whether all bits are unset.
True if none of the bits is set, and False otherwise. | bool CDPL.Util.BitSet.__getitem__ | ( | int | idx | ) |
Returns the value of the bit at index idx.
| idx | The zero-based index of the bit. |
| Base.IndexError | if idx is not in the range [0, getSize()). |
| None CDPL.Util.BitSet.__setitem__ | ( | int | idx, |
| bool | value | ||
| ) |
Sets the bit at index idx to value.
| idx | The zero-based index of the bit. |
| value | The new value of the bit. |
| Base.IndexError | if idx is not in the range [0, getSize()). |
Performs a bitwise‐AND of this bitset and the bitset bs.
| bs | The other BitSet instance. |
| Base.ValueError | if getSize() != bs.getSize(). |
Performs a bitwise‐OR of this bitset and the bitset bs.
| bs | The other BitSet instance. |
| Base.ValueError | if getSize() != bs.getSize(). |
Performs a bitwise‐XOR of this bitset and the bitset bs.
| bs | The other BitSet instance. |
| Base.ValueError | if getSize() != bs.getSize(). |
Computes the set difference of this bitset and the bitset bs.
| bs | The other BitSet instance. |
| Base.ValueError | if getSize() != bs.getSize(). |
Performs an in-place bitwise‐AND of this bitset and the bitset bs.
| bs | The other BitSet instance. |
| Base.ValueError | if getSize() != bs.getSize(). |
Performs an in-place bitwise‐OR of this bitset and the bitset bs.
| bs | The other BitSet instance. |
| Base.ValueError | if getSize() != bs.getSize(). |
Performs an in-place bitwise‐XOR of this bitset and the bitset bs.
| bs | The other BitSet instance. |
| Base.ValueError | if getSize() != bs.getSize(). |
Computes the in-place set difference of this bitset and the bitset bs.
| bs | The other BitSet instance. |
| Base.ValueError | if getSize() != bs.getSize(). |
| int CDPL.Util.BitSet.__long__ | ( | ) |
Returns the numeric value that corresponds to this bitset (0 if empty).
| RuntimeError | if that value is too large to be represented in an unsigned long. |
| BitSet CDPL.Util.BitSet.__ilshift__ | ( | int | num_bits | ) |
Shifts the bits to the left by num_bits positions.
| num_bits | The number of positions to shift. |
| BitSet CDPL.Util.BitSet.__lshift__ | ( | int | num_bits | ) |
Shifts the bits in a copy of this bitset to the left by num_bits positions.
| num_bits | The number of positions to shift. |
| BitSet CDPL.Util.BitSet.__irshift__ | ( | int | num_bits | ) |
Shifts the bits to the right by num_bits positions.
| num_bits | The number of positions to shift. |
| BitSet CDPL.Util.BitSet.__rshift__ | ( | int | num_bits | ) |
Shifts the bits in a copy of this bitset to the right by num_bits positions.
| num_bits | The number of positions to shift. |
| BitSet CDPL.Util.BitSet.__invert__ | ( | ) |
Toggles the value of every bit.
| bool CDPL.Util.BitSet.__eq__ | ( | BitSet | bs | ) |
Checks whether this bitset is equal to the bitset bs.
| bs | The other BitSet instance. |
True if this bitset is equal to bs, and False otherwise. | bool CDPL.Util.BitSet.__ne__ | ( | BitSet | bs | ) |
Checks whether this bitset is not equal to the bitset bs.
| bs | The other BitSet instance. |
True this bitset is not equal to bs, and False otherwise. | bool CDPL.Util.BitSet.__lt__ | ( | BitSet | bs | ) |
Checks whether this bitset is lexicographically less than the bitset bs.
| bs | The other BitSet instance. |
True if this bitset is lexicographically less than bs, and False otherwise. | bool CDPL.Util.BitSet.__le__ | ( | BitSet | bs | ) |
Checks whether this bitset is lexicographically less or equal to the bitset bs.
| bs | The other BitSet instance. |
True if this bitset is lexicographically less or equal to bs, and False otherwise. | bool CDPL.Util.BitSet.__gt__ | ( | BitSet | bs | ) |
Checks whether this bitset is lexicographically greater than the bitset bs.
| bs | The other BitSet instance. |
True if this bitset is lexicographically greater than bs, and False otherwise. | bool CDPL.Util.BitSet.__ge__ | ( | BitSet | bs | ) |
Checks whether this bitset is lexicographically greater or equal to the bitset bs.
| bs | The other BitSet instance. |
True if this bitset is lexicographically greater or equal to bs, and False otherwise. | int CDPL.Util.BitSet.__len__ | ( | ) |
Returns the size of the bitset.
| bool CDPL.Util.BitSet.__nonzero__ | ( | ) |
Checks whether at least one bit is set.
True if at least one bit is set, and False otherwise. | bool CDPL.Util.BitSet.__bool__ | ( | ) |
Checks whether at least one bit is set.
True if at least one bit is set, and False otherwise. | str CDPL.Util.BitSet.__str__ | ( | ) |
Returns a string representation of the BitSet instance.