# BitArray

from pandac.PandaModules import BitArray

Class : BitArray
Description : 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:

BitArray:

## Methods of BitArray:

allOff
allOn
bit
clear
clearBit
clearRange
compareTo
extract
getBit
getClassType
getHighestBits
getMaxNumBits
getNumBits
getNumBitsPerWord
getNumWords
getWord
hasBitsInCommon
hasMaxNumBits
invertInPlace
isZero
lowerOn
operator !=
operator &
operator &=
operator <
operator <<
operator <<=
operator =
operator ==
operator >>
operator >>=
operator ^
operator ^=
operator |
operator |=
operator ~
output
outputBinary
outputHex
range
setBit
setBitTo
setRange
setRangeTo
setWord
store
write

allOff static BitArray BitArray::all_off(void); Description: Returns a BitArray whose bits are all off.

allOn static BitArray BitArray::all_on(void); Description: Returns a BitArray with an infinite array of bits, all on.

bit static BitArray BitArray::bit(int index); Description: Returns a BitArray with only the indicated bit on.

clear void BitArray::clear(void); Description: Sets all the bits in the BitArray off.

clearBit void BitArray::clear_bit(int index); Description: Sets the nth bit off. If n >= get_num_bits(), this automatically extends the array.

clearRange void BitArray::clear_range(int low_bit, int size); Description: Sets the indicated range of bits off.

compareTo int BitArray::compare_to(BitArray const &other) const; Description: 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 unsigned int BitArray::extract(int low_bit, int size) const; Description: 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 bool BitArray::get_bit(int index) const; Description: 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 static TypeHandle BitArray::get_class_type(void); Undocumented function.

getHighestBits bool BitArray::get_highest_bits(void) const; Description: Returns true if the infinite set of bits beyond get_num_bits() are all on, or false of they are all off.

getMaxNumBits static int BitArray::get_max_num_bits(void); Description: If get_max_num_bits() returned true, this method may be called to return the maximum number of bits that may be stored in this structure. It is an error to call this if get_max_num_bits() return false. It is always an error to call this method. The BitArray has no maximum number of bits. This method is defined so generic programming algorithms can use BitMask or BitArray interchangeably.

getNumBits int BitArray::get_num_bits(void) const; Description: 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 static int BitArray::get_num_bits_per_word(void); Description: Returns the number of bits stored per word internally. This is of interest only in that it limits the maximum number of bits that may be queried or set at once by extract() and store().

getNumWords int BitArray::get_num_words(void) const; Description: Returns the number of possibly-unique words stored in the array.

getWord BitMask< unsigned int, 32 > BitArray::get_word(int n) const; Description: 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.

hasBitsInCommon bool BitArray::has_bits_in_common(BitArray const &other) const; Description: 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 static bool BitArray::has_max_num_bits(void); Description: Returns true if there is a maximum number of bits that may be stored in this structure, false otherwise. If this returns true, the number may be queried in get_max_num_bits(). This method always returns false. The BitArray has no maximum number of bits. This method is defined so generic programming algorithms can use BitMask or BitArray interchangeably.

invertInPlace void BitArray::invert_in_place(void); Description: Inverts all the bits in the BitArray. This is equivalent to array = ~array.

isZero bool BitArray::is_zero(void) const; Description: Returns true if the entire bitmask is zero, false otherwise.

lowerOn static BitArray BitArray::lower_on(int on_bits); Description: Returns a BitArray whose lower on_bits bits are on.

operator != bool BitArray::operator !=(BitArray const &other) const; Description:

operator & BitArray BitArray::operator &(BitArray const &other) const; Description:

operator &= void BitArray::operator &=(BitArray const &other); Description:

operator < bool BitArray::operator <(BitArray const &other) const; Description: Returns true if the unsigned integer which is represented by this BitArray is less than that of the other one, false otherwise.

operator << BitArray BitArray::operator <<(int shift) const; Description:

operator <<= void BitArray::operator <<=(int shift); Description: Logical left shift. The rightmost bits are filled in with zeroes. Since this is an infinite bit array, none of the bits on the left are lost.

operator = BitArray &BitArray::operator =(BitArray const &copy); Description:

operator == bool BitArray::operator ==(BitArray const &other) const; Description:

operator >> BitArray BitArray::operator >>(int shift) const; Description:

operator >>= void BitArray::operator >>=(int shift); Description: Logical right shift. The rightmost bits are lost. Since this is an infinite bit array, there is no question of sign extension; there is no need to synthesize bits on the left.

operator ^ BitArray BitArray::operator ^(BitArray const &other) const; Description:

operator ^= void BitArray::operator ^=(BitArray const &other); Description:

operator | BitArray BitArray::operator |(BitArray const &other) const; Description:

operator |= void BitArray::operator |=(BitArray const &other); Description:

operator ~ BitArray BitArray::operator ~(void) const; Undocumented function.

output void BitArray::output(ostream &out) const; Description: 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 void BitArray::output_binary(ostream &out, int spaces_every = (4)) const; Description: Writes the BitArray out as a binary number, with spaces every four bits.

outputHex void BitArray::output_hex(ostream &out, int spaces_every = (4)) const; Description: Writes the BitArray out as a hexadecimal number, with spaces every four digits.

range static BitArray BitArray::range(int low_bit, int size); Description: Returns a BitArray whose size bits, beginning at low_bit, are on.

setBit void BitArray::set_bit(int index); Description: Sets the nth bit on. If n >= get_num_bits(), this automatically extends the array.

setBitTo void BitArray::set_bit_to(int index, bool value); Description: Sets the nth bit either on or off, according to the indicated bool value.

setRange void BitArray::set_range(int low_bit, int size); Description: Sets the indicated range of bits on.

setRangeTo void BitArray::set_range_to(bool value, int low_bit, int size); Description: Sets the indicated range of bits to either on or off.

setWord void BitArray::set_word(int n, BitMask< unsigned int, 32 > value); Description: Replaces the nth word in the array. If n >= get_num_words(), this automatically extends the array.

store void BitArray::store(unsigned int value, int low_bit, int size); Description: Stores the indicated word into the indicated range of bits with this BitArray.

write void BitArray::write(ostream &out, int indent_level = (0)) const; Description: Writes the BitArray out as a binary or a hex number, according to the number of bits.