26 BitArray(WordType init_value) {
    27   if (init_value != 0) {
    28     _array.push_back(MaskType(init_value));
    39   result._highest_bits = 1;
   100   nassertr(index >= 0, 
false);
   101   int w = index / num_bits_per_word;
   102   int b = index % num_bits_per_word;
   116   nassertv(index >= 0);
   117   int w = index / num_bits_per_word;
   118   int b = index % num_bits_per_word;
   124   _array[w].set_bit(b);
   134   nassertv(index >= 0);
   135   int w = index / num_bits_per_word;
   136   int b = index % num_bits_per_word;
   142   _array[w].clear_bit(b);
   164   return (_highest_bits != 0);
   174   nassertr(size >= 0 && size <= num_bits_per_word, 0);
   175   int w = low_bit / num_bits_per_word;
   176   int b = low_bit % num_bits_per_word;
   178   if (b + size < num_bits_per_word) {
   180     return get_word(w).extract(b, size);
   184     int num_lower_bits = num_bits_per_word - b;
   185     int num_higher_bits = size - num_lower_bits;
   187     return get_word(w).extract(b, num_lower_bits) |
   188       (
get_word(w + 1).extract(0, num_higher_bits) << num_lower_bits);
   197 store(WordType value, 
int low_bit, 
int size) {
   199   int w = low_bit / num_bits_per_word;
   200   int b = low_bit % num_bits_per_word;
   202   if (b + size < num_bits_per_word) {
   205     _array[w].store(value, b, size);
   209     int num_lower_bits = num_bits_per_word - b;
   210     int num_higher_bits = size - num_lower_bits;
   212     ensure_has_word(w + 1);
   213     _array[w].store(value, b, num_lower_bits);
   214     _array[w + 1].store(value >> num_lower_bits, 0, num_higher_bits);
   236   return _array.size();
   246   nassertr(n >= 0, MaskType::all_off());
   251     return MaskType::all_on();
   253     return MaskType::all_off();
   280 INLINE 
bool BitArray::
   281 operator == (
const BitArray &other)
 const {
   288 INLINE 
bool BitArray::
   289 operator != (
const BitArray &other)
 const {
   306 operator & (
const BitArray &other)
 const {
   316 operator | (
const BitArray &other)
 const {
   326 operator ^ (
const BitArray &other)
 const {
   336 operator ~ ()
 const {
   338   result.invert_in_place();
   346 operator << (
int shift)
 const {
   356 operator >> (
int shift)
 const {
   367 INLINE 
void BitArray::
   369   if (_array.get_ref_count() > 1) {
   370     PTA(MaskType) new_array;
   371     new_array.v() = _array.v();
 void set_word(size_t n, WordType value)
Replaces the nth word in the array.
 
void set_bit_to(int index, bool value)
Sets the nth bit either on or off, according to the indicated bool value.
 
MaskType get_word(size_t n) const
Returns the nth word in the array.
 
bool get_highest_bits() const
Returns true if the infinite set of bits beyond get_num_bits() are all on, or false of they are all o...
 
bool get_bit(int index) const
Returns true if the nth bit is set, false if it is cleared.
 
static BitArray all_on()
Returns a BitArray with an infinite array of bits, all on.
 
static BitArray range(int low_bit, int size)
Returns a BitArray whose size bits, beginning at low_bit, are on.
 
void set_range_to(bool value, int low_bit, int size)
Sets the indicated range of bits to either on or off.
 
void store(WordType value, int low_bit, int size)
Stores the indicated word into the indicated range of bits with this BitArray.
 
void clear_bit(int index)
Sets the nth bit off.
 
A dynamic array with an unlimited number of bits.
 
bool operator<(const BitArray &other) const
Returns true if the unsigned integer which is represented by this BitArray is less than that of the o...
 
void set_range(int low_bit, int size)
Sets the indicated range of bits on.
 
void clear_range(int low_bit, int size)
Sets the indicated range of bits off.
 
static BitArray lower_on(int on_bits)
Returns a BitArray whose lower on_bits bits are on.
 
size_t get_num_words() const
Returns the number of possibly-unique words stored in the array.
 
void set_bit(int index)
Sets the nth bit on.
 
void clear()
Sets all the bits in the BitArray off.
 
size_t get_num_bits() const
Returns the current number of possibly different bits in this array.
 
static BitArray all_off()
Returns a BitArray whose bits are all off.
 
static BitArray bit(int index)
Returns a BitArray with only the indicated bit on.
 
WordType extract(int low_bit, int size) const
Returns a word that represents only the indicated range of bits within this BitArray,...
 
int compare_to(const BitArray &other) const
Returns a number less than zero if this BitArray sorts before the indicated other BitArray,...