BitArray
from panda3d.core import BitArray
- class BitArray
Bases:
DTOOL_SUPER_BASE
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
- __init__(*args, **kwargs)
- clearBit()
C++ Interface: clear_bit(const BitArray self, int index)
- /**
Sets the nth bit off. If n >= get_num_bits(), this automatically extends
the array.
*/
- clearRange()
C++ Interface: clear_range(const BitArray self, int low_bit, int size)
- /**
Sets the indicated range of bits off.
*/
- clear_bit()
C++ Interface: clear_bit(const BitArray self, int index)
- /**
Sets the nth bit off. If n >= get_num_bits(), this automatically extends
the array.
*/
- clear_range()
C++ Interface: clear_range(const BitArray self, int low_bit, int size)
- /**
Sets the indicated range of bits off.
*/
- compareTo()
C++ Interface: compare_to(BitArray self, const BitArray other)
- /**
Returns a number less than zero if this BitArray sorts before the indicated
other BitArray, greater than zero if it sorts after, or 0 if they are
equivalent. This is based on the same ordering defined by operator <.
*/
- compare_to()
C++ Interface: compare_to(BitArray self, const BitArray other)
- /**
Returns a number less than zero if this BitArray sorts before the indicated
other BitArray, greater than zero if it sorts after, or 0 if they are
equivalent. This is based on the same ordering defined by operator <.
*/
- extract()
C++ Interface: extract(BitArray self, int low_bit, int size)
- /**
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().
*/
- getBit()
C++ Interface: get_bit(BitArray self, int index)
- /**
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 value
get_num_bits() will always be the same.
*/
- getClassType()
C++ Interface: get_class_type()
- getHighestBits()
C++ Interface: get_highest_bits(BitArray self)
- /**
Returns true if the infinite set of bits beyond get_num_bits() are all on,
or false of they are all off.
*/
- getHighestOffBit()
C++ Interface: get_highest_off_bit(BitArray self)
- /**
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.
*/
- getHighestOnBit()
C++ Interface: get_highest_on_bit(BitArray self)
- /**
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.
*/
- getLowestOffBit()
C++ Interface: get_lowest_off_bit(BitArray self)
- /**
Returns the index of the lowest 0 bit in the array. Returns -1 if there
are no 0 bits.
*/
- getLowestOnBit()
C++ Interface: get_lowest_on_bit(BitArray self)
- /**
Returns the index of the lowest 1 bit in the array. Returns -1 if there
are no 1 bits.
*/
- getMaxNumBits()
C++ Interface: get_max_num_bits()
- getNextHigherDifferentBit()
C++ Interface: get_next_higher_different_bit(BitArray self, int low_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.
*/
- getNumBits()
C++ Interface: get_num_bits(BitArray self)
- /**
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.
*/
- getNumBitsPerWord()
C++ Interface: get_num_bits_per_word()
- getNumOffBits()
C++ Interface: get_num_off_bits(BitArray self)
- /**
Returns the number of bits that are set to 0 in the array. Returns -1 if
there are an infinite number of 0 bits.
*/
- getNumOnBits()
C++ Interface: get_num_on_bits(BitArray self)
- /**
Returns the number of bits that are set to 1 in the array. Returns -1 if
there are an infinite number of 1 bits.
*/
- getNumWords()
C++ Interface: get_num_words(BitArray self)
- /**
Returns the number of possibly-unique words stored in the array.
*/
- getWord()
C++ Interface: get_word(BitArray self, int n)
- /**
Returns the nth word in the array. It is valid for n to be greater than
get_num_words(), but the return value beyond get_num_words() will always be
the same.
*/
- get_bit()
C++ Interface: get_bit(BitArray self, int index)
- /**
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 value
get_num_bits() will always be the same.
*/
- get_class_type()
C++ Interface: get_class_type()
- get_highest_bits()
C++ Interface: get_highest_bits(BitArray self)
- /**
Returns true if the infinite set of bits beyond get_num_bits() are all on,
or false of they are all off.
*/
- get_highest_off_bit()
C++ Interface: get_highest_off_bit(BitArray self)
- /**
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.
*/
- get_highest_on_bit()
C++ Interface: get_highest_on_bit(BitArray self)
- /**
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.
*/
- get_lowest_off_bit()
C++ Interface: get_lowest_off_bit(BitArray self)
- /**
Returns the index of the lowest 0 bit in the array. Returns -1 if there
are no 0 bits.
*/
- get_lowest_on_bit()
C++ Interface: get_lowest_on_bit(BitArray self)
- /**
Returns the index of the lowest 1 bit in the array. Returns -1 if there
are no 1 bits.
*/
- get_max_num_bits()
C++ Interface: get_max_num_bits()
- get_next_higher_different_bit()
C++ Interface: get_next_higher_different_bit(BitArray self, int low_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.
*/
- get_num_bits()
C++ Interface: get_num_bits(BitArray self)
- /**
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.
*/
- get_num_bits_per_word()
C++ Interface: get_num_bits_per_word()
- get_num_off_bits()
C++ Interface: get_num_off_bits(BitArray self)
- /**
Returns the number of bits that are set to 0 in the array. Returns -1 if
there are an infinite number of 0 bits.
*/
- get_num_on_bits()
C++ Interface: get_num_on_bits(BitArray self)
- /**
Returns the number of bits that are set to 1 in the array. Returns -1 if
there are an infinite number of 1 bits.
*/
- get_num_words()
C++ Interface: get_num_words(BitArray self)
- /**
Returns the number of possibly-unique words stored in the array.
*/
- get_word()
C++ Interface: get_word(BitArray self, int n)
- /**
Returns the nth word in the array. It is valid for n to be greater than
get_num_words(), but the return value beyond get_num_words() will always be
the same.
*/
- hasAllOf()
C++ Interface: has_all_of(BitArray self, int low_bit, int size)
- /**
Returns true if all bits in the indicated range are set, false otherwise.
*/
- hasAnyOf()
C++ Interface: has_any_of(BitArray self, int low_bit, int size)
- /**
Returns true if any bit in the indicated range is set, false otherwise.
*/
- hasBitsInCommon()
C++ Interface: has_bits_in_common(BitArray self, const BitArray other)
- /**
Returns true if this BitArray has any “one” bits in common with the other
one, false otherwise.
This is equivalent to (array & other) != 0, but may be faster.
*/
- hasMaxNumBits()
C++ Interface: has_max_num_bits()
- has_all_of()
C++ Interface: has_all_of(BitArray self, int low_bit, int size)
- /**
Returns true if all bits in the indicated range are set, false otherwise.
*/
- has_any_of()
C++ Interface: has_any_of(BitArray self, int low_bit, int size)
- /**
Returns true if any bit in the indicated range is set, false otherwise.
*/
- has_bits_in_common()
C++ Interface: has_bits_in_common(BitArray self, const BitArray other)
- /**
Returns true if this BitArray has any “one” bits in common with the other
one, false otherwise.
This is equivalent to (array & other) != 0, but may be faster.
*/
- has_max_num_bits()
C++ Interface: has_max_num_bits()
- invertInPlace()
C++ Interface: invert_in_place(const BitArray self)
- /**
Inverts all the bits in the BitArray. This is equivalent to array =
~array.
*/
- invert_in_place()
C++ Interface: invert_in_place(const BitArray self)
- /**
Inverts all the bits in the BitArray. This is equivalent to array =
~array.
*/
- isAllOn()
C++ Interface: is_all_on(BitArray self)
- /**
Returns true if the entire bitmask is one, false otherwise.
*/
- isZero()
C++ Interface: is_zero(BitArray self)
- /**
Returns true if the entire bitmask is zero, false otherwise.
*/
- is_all_on()
C++ Interface: is_all_on(BitArray self)
- /**
Returns true if the entire bitmask is one, false otherwise.
*/
- is_zero()
C++ Interface: is_zero(BitArray self)
- /**
Returns true if the entire bitmask is zero, false otherwise.
*/
- lowerOn()
C++ Interface: lower_on(int on_bits)
- /**
Returns a BitArray whose lower on_bits bits are on.
*/
- lower_on()
C++ Interface: lower_on(int on_bits)
- /**
Returns a BitArray whose lower on_bits bits are on.
*/
- num_bits_per_word = 64
- output()
C++ Interface: output(BitArray self, ostream out)
- /**
Writes the BitArray out as a hex number. For a BitArray, this is always
the same as output_hex(); it’s too confusing for the output format to
change back and forth at runtime.
*/
- outputBinary()
C++ Interface: output_binary(BitArray self, ostream out, int spaces_every)
- /**
Writes the BitArray out as a binary number, with spaces every four bits.
*/
- outputHex()
C++ Interface: output_hex(BitArray self, ostream out, int spaces_every)
- /**
Writes the BitArray out as a hexadecimal number, with spaces every four
digits.
*/
- output_binary()
C++ Interface: output_binary(BitArray self, ostream out, int spaces_every)
- /**
Writes the BitArray out as a binary number, with spaces every four bits.
*/
- output_hex()
C++ Interface: output_hex(BitArray self, ostream out, int spaces_every)
- /**
Writes the BitArray out as a hexadecimal number, with spaces every four
digits.
*/
- range()
C++ Interface: range(int low_bit, int size)
- /**
Returns a BitArray whose size bits, beginning at low_bit, are on.
*/
- setBit()
C++ Interface: set_bit(const BitArray self, int index)
- /**
Sets the nth bit on. If n >= get_num_bits(), this automatically extends
the array.
*/
- setBitTo()
C++ Interface: set_bit_to(const BitArray self, int index, bool value)
- /**
Sets the nth bit either on or off, according to the indicated bool value.
*/
- setRange()
C++ Interface: set_range(const BitArray self, int low_bit, int size)
- /**
Sets the indicated range of bits on.
*/
- setRangeTo()
C++ Interface: set_range_to(const BitArray self, bool value, int low_bit, int size)
- /**
Sets the indicated range of bits to either on or off.
*/
- setWord()
C++ Interface: set_word(const BitArray self, int n, long value)
- /**
Replaces the nth word in the array. If n >= get_num_words(), this
automatically extends the array.
*/
- set_bit()
C++ Interface: set_bit(const BitArray self, int index)
- /**
Sets the nth bit on. If n >= get_num_bits(), this automatically extends
the array.
*/
- set_bit_to()
C++ Interface: set_bit_to(const BitArray self, int index, bool value)
- /**
Sets the nth bit either on or off, according to the indicated bool value.
*/
- set_range()
C++ Interface: set_range(const BitArray self, int low_bit, int size)
- /**
Sets the indicated range of bits on.
*/
- set_range_to()
C++ Interface: set_range_to(const BitArray self, bool value, int low_bit, int size)
- /**
Sets the indicated range of bits to either on or off.
*/
- set_word()
C++ Interface: set_word(const BitArray self, int n, long value)
- /**
Replaces the nth word in the array. If n >= get_num_words(), this
automatically extends the array.
*/