BitArray

from panda3d.core import BitArray
class BitArray

Bases:

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

Inheritance diagram of BitArray

__and__(other: BitArray) BitArray
__bool__() bool
__eq__(other: BitArray) bool
__getstate__() object
__iand__(other: BitArray) BitArray
__ilshift__(shift: int) BitArray
__init__()
__init__(param0: BitArray)
__init__(init_value: object)
__init__(from: SparseArray)
__ior__(other: BitArray) BitArray
__irshift__(shift: int) BitArray
__ixor__(other: BitArray) BitArray
__lt__(other: BitArray) bool
__ne__(other: BitArray) bool
__or__(other: BitArray) BitArray
__rshift__(shift: int) BitArray
__setstate__(state: object)
__xor__(other: BitArray) BitArray
static all_off() BitArray

Returns a BitArray whose bits are all off.

static all_on() BitArray

Returns a BitArray with an infinite array of bits, all on.

static bit(index: int) BitArray

Returns a BitArray with only the indicated bit on.

clear()

Sets all the bits in the BitArray off.

clear_bit(index: int)

Sets the nth bit off. If n >= get_num_bits(), this automatically extends the array.

clear_range(low_bit: int, size: int)

Sets the indicated range of bits off.

compare_to(other: BitArray) int

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(low_bit: int, size: int) int

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().

get_bit(index: int) bool

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.

static get_class_type() TypeHandle
get_highest_bits() bool

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() int

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() int

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() int

Returns the index of the lowest 0 bit in the array. Returns -1 if there are no 0 bits.

get_lowest_on_bit() int

Returns the index of the lowest 1 bit in the array. Returns -1 if there are no 1 bits.

static get_max_num_bits() int
get_next_higher_different_bit(low_bit: int) int

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() int

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 get_num_bits_per_word() int
get_num_off_bits() int

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() int

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() int

Returns the number of possibly-unique words stored in the array.

get_word(n: int) MaskType

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.

has_all_of(low_bit: int, size: int) bool

Returns true if all bits in the indicated range are set, false otherwise.

has_any_of(low_bit: int, size: int) bool

Returns true if any bit in the indicated range is set, false otherwise.

has_bits_in_common(other: BitArray) bool

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.

static has_max_num_bits() bool
invert_in_place()

Inverts all the bits in the BitArray. This is equivalent to array = ~array.

is_all_on() bool

Returns true if the entire bitmask is one, false otherwise.

is_zero() bool

Returns true if the entire bitmask is zero, false otherwise.

static lower_on(on_bits: int) BitArray

Returns a BitArray whose lower on_bits bits are on.

operator__() BitArray
operator___(shift: int) BitArray
output(out: ostream)

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.

output_binary(out: ostream, spaces_every: int)

Writes the BitArray out as a binary number, with spaces every four bits.

output_hex(out: ostream, spaces_every: int)

Writes the BitArray out as a hexadecimal number, with spaces every four digits.

static range(low_bit: int, size: int) BitArray

Returns a BitArray whose size bits, beginning at low_bit, are on.

set_bit(index: int)

Sets the nth bit on. If n >= get_num_bits(), this automatically extends the array.

set_bit_to(index: int, value: bool)

Sets the nth bit either on or off, according to the indicated bool value.

set_range(low_bit: int, size: int)

Sets the indicated range of bits on.

set_range_to(value: bool, low_bit: int, size: int)

Sets the indicated range of bits to either on or off.

set_word(n: int, value: int)

Replaces the nth word in the array. If n >= get_num_words(), this automatically extends the array.

store(value: int, low_bit: int, size: int)

Stores the indicated word into the indicated range of bits with this BitArray.

write(out: ostream, indent_level: int)

Writes the BitArray out as a binary or a hex number, according to the number of bits.