panda3d.core.BitArray

from panda3d.core import 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

Inheritance diagram of BitArray

__init__() → None
__init__(param0: BitArray) → None
__init__(init_value: WordType) → None
__init__(from: SparseArray) → None
static allOn() → BitArray

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

Return type

BitArray

static allOff() → BitArray

Returns a BitArray whose bits are all off.

Return type

BitArray

static lowerOn(on_bits: int) → BitArray

Returns a BitArray whose lower on_bits bits are on.

Return type

BitArray

static bit(index: int) → BitArray

Returns a BitArray with only the indicated bit on.

Return type

BitArray

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

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

Return type

BitArray

static hasMaxNumBits() → bool
static getMaxNumBits() → int
static getNumBitsPerWord() → int
getNumBits() → size_t

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

This number may grow and/or shrink automatically as needed.

Return type

size_t

getBit(index: int) → bool

Returns true if the nth bit is set, false if it is cleared. It is valid for n to increase beyond getNumBits(), but the return value getNumBits() will always be the same.

setBit(index: int) → None

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

clearBit(index: int) → None

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

setBitTo(index: int, value: bool) → None

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

getHighestBits() → bool

Returns true if the infinite set of bits beyond getNumBits() are all on, or false of they are all off.

isZero() → bool

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

isAllOn() → bool

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

extract(low_bit: int, size: int) → WordType

Returns a word that represents only the indicated range of bits within this BitArray, shifted to the least-significant position. size must be <= getNumBitsPerWord().

Return type

WordType

store(value: WordType, low_bit: int, size: int) → None

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

hasAnyOf(low_bit: int, size: int) → bool

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

hasAllOf(low_bit: int, size: int) → bool

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

setRange(low_bit: int, size: int) → None

Sets the indicated range of bits on.

clearRange(low_bit: int, size: int) → None

Sets the indicated range of bits off.

setRangeTo(value: bool, low_bit: int, size: int) → None

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

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

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

getLowestOnBit() → int

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

getLowestOffBit() → int

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

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

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

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

getNumWords() → size_t

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

Return type

size_t

getWord(n: size_t) → MaskType

Returns the nth word in the array. It is valid for n to be greater than getNumWords(), but the return value beyond getNumWords() will always be the same.

Return type

MaskType

setWord(n: size_t, value: WordType) → None

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

invertInPlace() → None

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

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

clear() → None

Sets all the bits in the BitArray off.

output(out: ostream) → None

Writes the BitArray out as a hex number. For a BitArray, this is always the same as outputHex(); it’s too confusing for the output format to change back and forth at runtime.

outputBinary(out: ostream, spaces_every: int) → None

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

outputHex(out: ostream, spaces_every: int) → None

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

write(out: ostream, indent_level: int) → None

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

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

operator(shift: int) → BitArray
Return type

BitArray

operator(shift: int) → BitArray
Return type

BitArray

static getClassType() → TypeHandle
Return type

TypeHandle