BitArray¶
-
class BitArray¶
A dynamic array with an unlimited number of bits.
This is similar to a BitMask, except it appears to contain an infinite number of bits. You can use it very much as you would use a BitMask.
Inheritance diagram
digraph inheritance11b700d743 { bgcolor=transparent; rankdir=BT; size="8.0, 12.0"; "BitArray" [URL="acron.core.BitArray.html#acron.core.BitArray",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "DTOOL_SUPER_BASE" -> "BitArray" [arrowsize=0.75,style=""]; "DTOOL_SUPER_BASE" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style=""]; }- BitArray.__and__()¶
- BitArray.__bool__()¶
- BitArray.__eq__()¶
- BitArray.__getstate__()¶
- BitArray.__iand__()¶
- BitArray.__ilshift__()¶
- BitArray.__init__()¶
- BitArray.__ior__()¶
- BitArray.__irshift__()¶
- BitArray.__ixor__()¶
- BitArray.__lt__()¶
- BitArray.__ne__()¶
- BitArray.__or__()¶
- BitArray.__rshift__()¶
- BitArray.__setstate__()¶
- BitArray.__xor__()¶
- BitArray.clear_bit()¶
Sets the nth bit off. If n >=
get_num_bits(), this automatically extends the array.
- BitArray.clear_range()¶
Sets the indicated range of bits off.
- BitArray.compare_to()¶
Returns a number less than zero if this
BitArraysorts before the indicated otherBitArray, greater than zero if it sorts after, or 0 if they are equivalent. This is based on the same ordering defined by operator <.
- BitArray.extract()¶
Returns a word that represents only the indicated range of bits within this
BitArray, shifted to the least-significant position. size must be <=get_num_bits_per_word().
- BitArray.get_bit()¶
Returns true if the nth bit is set, false if it is cleared. It is valid for n to increase beyond
get_num_bits(), but the return valueget_num_bits()will always be the same.
- static BitArray.get_class_type()¶
- BitArray.get_highest_bits()¶
Returns true if the infinite set of bits beyond
get_num_bits()are all on, or false of they are all off.
- BitArray.get_highest_off_bit()¶
Returns the index of the highest 0 bit in the array. Returns -1 if there are no 0 bits or if there an infinite number of 1 bits.
- BitArray.get_highest_on_bit()¶
Returns the index of the highest 1 bit in the array. Returns -1 if there are no 1 bits or if there an infinite number of 1 bits.
- BitArray.get_lowest_off_bit()¶
Returns the index of the lowest 0 bit in the array. Returns -1 if there are no 0 bits.
- BitArray.get_lowest_on_bit()¶
Returns the index of the lowest 1 bit in the array. Returns -1 if there are no 1 bits.
- static BitArray.get_max_num_bits()¶
- BitArray.get_next_higher_different_bit()¶
Returns the index of the next bit in the array, above low_bit, whose value is different that the value of low_bit. Returns low_bit again if all bits higher than low_bit have the same value.
This can be used to quickly iterate through all of the bits in the array.
- BitArray.get_num_bits()¶
Returns the current number of possibly different bits in this array. There are actually an infinite number of bits, but every bit higher than this bit will have the same value, either 0 or 1 (see
get_highest_bits()).This number may grow and/or shrink automatically as needed.
- static BitArray.get_num_bits_per_word()¶
- BitArray.get_num_off_bits()¶
Returns the number of bits that are set to 0 in the array. Returns -1 if there are an infinite number of 0 bits.
- BitArray.get_num_on_bits()¶
Returns the number of bits that are set to 1 in the array. Returns -1 if there are an infinite number of 1 bits.
- BitArray.get_num_words()¶
Returns the number of possibly-unique words stored in the array.
- BitArray.get_word()¶
Returns the nth word in the array. It is valid for n to be greater than
get_num_words(), but the return value beyondget_num_words()will always be the same.
- BitArray.has_all_of()¶
Returns true if all bits in the indicated range are set, false otherwise.
- BitArray.has_any_of()¶
Returns true if any bit in the indicated range is set, false otherwise.
- BitArray.has_bits_in_common()¶
Returns true if this
BitArrayhas any “one” bits in common with the other one, false otherwise.This is equivalent to (array & other) != 0, but may be faster.
- static BitArray.has_max_num_bits()¶
- BitArray.invert_in_place()¶
Inverts all the bits in the
BitArray. This is equivalent to array = ~array.
- BitArray.is_all_on()¶
Returns true if the entire bitmask is one, false otherwise.
- BitArray.is_zero()¶
Returns true if the entire bitmask is zero, false otherwise.
- BitArray.operator__()¶
- BitArray.operator___()¶
- BitArray.output()¶
Writes the
BitArrayout as a hex number. For aBitArray, this is always the same asoutput_hex(); it’s too confusing for the output format to change back and forth at runtime.
- BitArray.output_hex()¶
Writes the
BitArrayout as a hexadecimal number, with spaces every four digits.
- BitArray.set_bit()¶
Sets the nth bit on. If n >=
get_num_bits(), this automatically extends the array.
- BitArray.set_bit_to()¶
Sets the nth bit either on or off, according to the indicated bool value.
- BitArray.set_range()¶
Sets the indicated range of bits on.
- BitArray.set_range_to()¶
Sets the indicated range of bits to either on or off.
- BitArray.set_word()¶
Replaces the nth word in the array. If n >=
get_num_words(), this automatically extends the array.