Panda3D
Loading...
Searching...
No Matches
bitMask.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file bitMask.I
10 * @author drose
11 * @date 2000-06-08
12 */
13
14template<class WType, int nbits>
16
17/**
18 *
19 */
20template<class WType, int nbits>
22BitMask(WordType init_value) :
23 _word(init_value)
24{
25}
26
27/**
28 * Returns a BitMask whose bits are all on.
29 */
30template<class WType, int nbits>
32all_on() {
33 BitMask result;
34 result._word = (WordType)~0;
35 return result;
36}
37
38/**
39 * Returns a BitMask whose bits are all off.
40 */
41template<class WType, int nbits>
44 BitMask result;
45 result._word = 0;
46 return result;
47}
48
49/**
50 * Returns a BitMask whose lower on_bits bits are on.
51 */
52template<class WType, int nbits>
54lower_on(int on_bits) {
55 if (on_bits <= 0) {
56 return all_off();
57 } else if (on_bits >= num_bits) {
58 return all_on();
59 }
60 BitMask result;
61 result._word = ((WordType)1 << on_bits) - 1;
62 return result;
65/**
66 * Returns a BitMask with only the indicated bit on.
67 */
68template<class WType, int nbits>
70bit(int index) {
71 BitMask result;
72 result.set_bit(index);
73 return result;
76/**
77 * Returns a BitMask whose size bits, beginning at low_bit, are on.
78 */
79template<class WType, int nbits>
81range(int low_bit, int size) {
82 BitMask result;
83 if (size <= 0) {
84 result._word = 0;
85 } else if (size >= num_bits) {
86 result._word = (WordType)~0;
87 } else {
88 result._word = ((WordType)1 << size) - 1;
89 }
90 result._word <<= low_bit;
91 return result;
92}
93
94/**
95 * Returns the number of bits available to set in the bitmask.
96 */
97template<class WType, int nbits>
99get_num_bits() const {
100 return num_bits;
101}
102
103/**
104 * Returns true if the nth bit is set, false if it is cleared. index must be
105 * in the range [0, num_bits).
106 */
107template<class WType, int nbits>
109get_bit(int index) const {
110 nassertr(index >= 0 && index < num_bits, false);
111 return (_word & ((WordType)1 << index)) != 0;
112}
113
114/**
115 * Sets the nth bit on. index must be in the range [0, num_bits).
116 */
117template<class WType, int nbits>
119set_bit(int index) {
120 nassertv(index >= 0 && index < num_bits);
121 _word |= ((WordType)1 << index);
124/**
125 * Sets the nth bit off. index must be in the range [0, num_bits).
126 */
127template<class WType, int nbits>
129clear_bit(int index) {
130 nassertv(index >= 0 && index < num_bits);
131 _word &= ~((WordType)1 << index);
133
134/**
135 * Sets the nth bit either on or off, according to the indicated bool value.
136 * index must be in the range [0, num_bits).
137 */
138template<class WType, int nbits>
140set_bit_to(int index, bool value) {
141 if (value) {
142 set_bit(index);
143 } else {
144 clear_bit(index);
145 }
146}
147
148/**
149 * Returns true if the entire bitmask is zero, false otherwise.
150 */
151template<class WType, int nbits>
153is_zero() const {
154 return (_word == 0);
155}
156
157/**
158 * Returns true if the entire bitmask is one, false otherwise.
159 */
160template<class WType, int nbits>
162is_all_on() const {
163 return _word == (WordType)~0;
164}
165
166/**
167 * Returns a word that represents only the indicated range of bits within this
168 * BitMask, shifted to the least-significant position.
169 */
170template<class WType, int nbits>
171INLINE typename BitMask<WType, nbits>::WordType BitMask<WType, nbits>::
172extract(int low_bit, int size) const {
173 return (_word >> low_bit) &
175}
176
177/**
178 * Stores the indicated word into the indicated range of bits with this
179 * BitMask.
180 */
181template<class WType, int nbits>
183store(WordType value, int low_bit, int size) {
184 WordType mask = BitMask<WType, nbits>::range(low_bit, size)._word;
185 _word = (_word & ~mask) | ((value << low_bit) & mask);
186}
187
188/**
189 * Returns true if any bit in the indicated range is set, false otherwise.
190 */
191template<class WType, int nbits>
193has_any_of(int low_bit, int size) const {
194 WordType mask = BitMask<WType, nbits>::range(low_bit, size)._word;
195 return (_word & mask) != 0;
196}
197
198/**
199 * Returns true if all bits in the indicated range are set, false otherwise.
200 */
201template<class WType, int nbits>
203has_all_of(int low_bit, int size) const {
204 WordType mask = BitMask<WType, nbits>::range(low_bit, size)._word;
205 return (_word & mask) == mask;
206}
207
208/**
209 * Sets the indicated range of bits on.
210 */
211template<class WType, int nbits>
213set_range(int low_bit, int size) {
214 WordType mask = BitMask<WType, nbits>::range(low_bit, size)._word;
215 _word |= mask;
216}
217
218/**
219 * Sets the indicated range of bits off.
220 */
221template<class WType, int nbits>
223clear_range(int low_bit, int size) {
224 WordType mask = BitMask<WType, nbits>::range(low_bit, size)._word;
225 _word &= ~mask;
226}
227
228/**
229 * Sets the indicated range of bits to either on or off.
230 */
231template<class WType, int nbits>
233set_range_to(bool value, int low_bit, int size) {
234 if (value) {
235 set_range(low_bit, size);
236 } else {
237 clear_range(low_bit, size);
238 }
239}
240
241/**
242 * Returns the entire BitMask as a single word.
243 */
244template<class WType, int nbits>
245INLINE typename BitMask<WType, nbits>::WordType BitMask<WType, nbits>::
246get_word() const {
247 return _word;
248}
249
250/**
251 * Sets the entire BitMask to the value indicated by the given word.
252 */
253template<class WType, int nbits>
255set_word(WordType value) {
256 _word = value;
257}
258
259/**
260 * Returns the number of bits that are set to 1 in the mask.
261 */
262template<class WType, int nbits>
264get_num_on_bits() const {
265 return count_bits_in_word((WType)_word);
266}
267
268/**
269 * Returns the number of bits that are set to 0 in the mask.
270 */
271template<class WType, int nbits>
273get_num_off_bits() const {
274 return count_bits_in_word((WType)(~_word));
275}
276
277/**
278 * Returns the index of the lowest 1 bit in the mask. Returns -1 if there are
279 * no 1 bits.
280 */
281template<class WType, int nbits>
283get_lowest_on_bit() const {
284 return ::get_lowest_on_bit(_word);
285}
286
287/**
288 * Returns the index of the lowest 0 bit in the mask. Returns -1 if there are
289 * no 0 bits.
290 */
291template<class WType, int nbits>
293get_lowest_off_bit() const {
294 return (~(*this)).get_lowest_on_bit();
295}
296
297/**
298 * Returns the index of the highest 1 bit in the mask. Returns -1 if there
299 * are no 1 bits.
300 */
301template<class WType, int nbits>
303get_highest_on_bit() const {
304 return ::get_highest_on_bit(_word);
305}
306
307/**
308 * Returns the index of the highest 0 bit in the mask. Returns -1 if there
309 * are no 0 bits.
310 */
311template<class WType, int nbits>
313get_highest_off_bit() const {
314 return (~(*this)).get_highest_on_bit();
315}
316
317/**
318 * Returns the index of the next bit in the mask, above low_bit, whose value
319 * is different that the value of low_bit. Returns low_bit again if all bits
320 * higher than low_bit have the same value.
321 *
322 * This can be used to quickly iterate through all of the bits in the mask.
323 */
324template<class WType, int nbits>
326get_next_higher_different_bit(int low_bit) const {
327 // We are allowed to call this method with low_bit == num_bits, which is the
328 // highest value this method will return.
329 nassertr(low_bit >= 0, low_bit);
330 if (low_bit >= num_bits) {
331 return low_bit;
332 }
333
334 WordType is_on = (_word & ((WordType)1 << low_bit));
335 WordType w;
336 if (is_on) {
337 // low_bit is 1. Get the next higher 0 bit. To do this, invert the word
338 // and the get the next higher 1 bit.
339 w = ~_word;
340 } else {
341 // low_bit is 0. Get the next higher 1 bit.
342 w = _word;
343 }
344
345 // Mask out all of the bits below low_bit. Since we already know that
346 // low_bit is 0, we can use (1 << low_bit) instead of (1 << (low_bit + 1)),
347 // which becomes undefined when (low_bit + 1) == 32.
348 w &= ~(((WordType)1 << low_bit) - 1);
349
350 if (w == 0) {
351 // All higher bits in the word have the same value. Since every bit after
352 // the topmost bit is 0, we either return the topmost bit + 1 to indicate
353 // the next 0 bit, or low_bit to indicate we have reached the end of the
354 // number of bits.
355 return is_on ? num_bits : low_bit;
356
357 } else {
358 // Now determine the lowest 1 bit in the remaining word. This operation
359 // will clear out all bits except for the lowest 1 bit.
360 w = (w & (~w + 1));
361
362 // And the answer is the number of bits in (w - 1).
363 return count_bits_in_word((WType)(w - 1));
364 }
365}
366
367/**
368 * Inverts all the bits in the BitMask. This is equivalent to mask = ~mask.
369 */
370template<class WType, int nbits>
373 _word = ~_word;
374}
375
376/**
377 * Returns true if this BitMask has any "one" bits in common with the other
378 * one, false otherwise.
379 *
380 * This is equivalent to (mask & other) != 0, but may be faster. (Actually,
381 * it should only be faster in the BitArray case, but this method is provided
382 * for the benefit of generic programming algorithms).
383 */
384template<class WType, int nbits>
386has_bits_in_common(const BitMask<WType, nbits> &other) const {
387 return (_word & other._word) != 0;
388}
389
390/**
391 * Sets all the bits in the BitMask off.
392 */
393template<class WType, int nbits>
395clear() {
396 _word = 0;
397}
398
399/**
400 * Writes the BitMask out as a binary or a hex number, according to the number
401 * of bits.
402 */
403template<class WType, int nbits>
405output(std::ostream &out) const {
406 if (num_bits >= 40) {
407 output_hex(out);
408 } else {
409 output_binary(out);
410 }
411}
412
413/**
414 * Writes the BitMask out as a binary number, with spaces every four bits.
415 */
416template<class WType, int nbits>
418output_binary(std::ostream &out, int spaces_every) const {
419 for (int i = num_bits - 1; i >= 0; i--) {
420 if (spaces_every != 0 && ((i % spaces_every) == spaces_every - 1)) {
421 out << ' ';
422 }
423 out << (get_bit(i) ? '1' : '0');
424 }
425}
426
427/**
428 * Writes the BitMask out as a hexadecimal number, with spaces every four
429 * digits.
430 */
431template<class WType, int nbits>
433output_hex(std::ostream &out, int spaces_every) const {
434 int num_digits = (num_bits + 3) / 4;
435
436 for (int i = num_digits - 1; i >= 0; i--) {
437 WordType digit = extract(i * 4, 4);
438 if (spaces_every != 0 && ((i % spaces_every) == spaces_every - 1)) {
439 out << ' ';
440 }
441 if (digit > 9) {
442 out << (char)(digit - 10 + 'a');
443 } else {
444 out << (char)(digit + '0');
445 }
446 }
447}
448
449/**
450 * Writes the BitMask out as a binary or a hex number, according to the number
451 * of bits.
452 */
453template<class WType, int nbits>
455write(std::ostream &out, int indent_level) const {
456 indent(out, indent_level) << *this << "\n";
457}
458
459/**
460 *
461 */
462template<class WType, int nbits>
463INLINE bool BitMask<WType, nbits>::
464operator == (const BitMask<WType, nbits> &other) const {
465 return _word == other._word;
466}
467
468/**
469 *
470 */
471template<class WType, int nbits>
472INLINE bool BitMask<WType, nbits>::
473operator != (const BitMask<WType, nbits> &other) const {
474 return _word != other._word;
475}
476
477/**
478 * The ordering operator is of limited usefulness with a BitMask, however, it
479 * has a definition which places all unique BitMasks into a unique ordering.
480 * It may be useful when defining ordered STL containers of BitMasks, for
481 * instance; and it's required in order to export any STL container (ordered
482 * or unordered) of BitMask under Windows.
483 */
484template<class WType, int nbits>
486operator < (const BitMask<WType, nbits> &other) const {
487 return _word < other._word;
488}
489
490/**
491 * Returns a number less than zero if this BitMask sorts before the indicated
492 * other BitMask, greater than zero if it sorts after, or 0 if they are
493 * equivalent. This is based on the same ordering defined by operator <.
494 */
495template<class WType, int nbits>
497compare_to(const BitMask<WType, nbits> &other) const {
498 if ((*this) < other) {
499 return -1;
500 } else if (other < (*this)) {
501 return 1;
502 } else {
503 return 0;
504 }
505}
506
507/**
508 *
509 */
510template<class WType, int nbits>
512operator & (const BitMask<WType, nbits> &other) const {
513 BitMask<WType, nbits> result(*this);
514 result &= other;
515 return result;
516}
517
518/**
519 *
520 */
521template<class WType, int nbits>
523operator | (const BitMask<WType, nbits> &other) const {
524 BitMask<WType, nbits> result(*this);
525 result |= other;
526 return result;
527}
528
529/**
530 *
531 */
532template<class WType, int nbits>
534operator ^ (const BitMask<WType, nbits> &other) const {
535 BitMask<WType, nbits> result(*this);
536 result ^= other;
537 return result;
538}
539
540/**
541 *
542 */
543template<class WType, int nbits>
545operator ~ () const {
546 return BitMask<WType, nbits>(~_word);
547}
548
549/**
550 *
551 */
552template<class WType, int nbits>
554operator << (int shift) const {
555 BitMask<WType, nbits> result(*this);
556 result <<= shift;
557 return result;
558}
559
560/**
561 *
562 */
563template<class WType, int nbits>
565operator >> (int shift) const {
566 BitMask<WType, nbits> result(*this);
567 result >>= shift;
568 return result;
569}
570
571/**
572 *
573 */
574template<class WType, int nbits>
575INLINE void BitMask<WType, nbits>::
577 _word &= other._word;
578}
579
580/**
581 *
582 */
583template<class WType, int nbits>
584INLINE void BitMask<WType, nbits>::
586 _word |= other._word;
587}
588
589/**
590 *
591 */
592template<class WType, int nbits>
593INLINE void BitMask<WType, nbits>::
595 _word ^= other._word;
596}
597
598/**
599 *
600 */
601template<class WType, int nbits>
602INLINE void BitMask<WType, nbits>::
603operator <<= (int shift) {
604 _word <<= shift;
605}
606
607/**
608 *
609 */
610template<class WType, int nbits>
611INLINE void BitMask<WType, nbits>::
612operator >>= (int shift) {
613 _word >>= shift;
614}
615
616/**
617 * Returns a mostly unique integer key per unique bitmask, suitable for using
618 * in a hash table.
619 */
620template<class WType, int nbits>
622get_key() const {
623 return (int)_word;
624}
625
626/**
627 * Returns true if the bitmask is not zero.
628 */
629template<class WType, int nbits>
631__nonzero__() const {
632 return _word != 0;
633}
634
635/**
636 * Adds the bitmask to the indicated hash generator.
637 */
638template<class WType, int nbits>
640generate_hash(ChecksumHashGenerator &hashgen) const {
641 hashgen.add_int(_word);
642}
643
644/**
645 *
646 */
647template<class WType, int nbits>
649init_type(const std::string &name) {
650 register_type(_type_handle, name);
651}
652
653/**
654 * Floods this bitmask's bits upwards.
655 */
656template<class WType, int nbits>
659 _word = ::flood_bits_up(_word);
660}
661
662/**
663 * Floods this bitmask's bits downwards.
664 */
665template<class WType, int nbits>
668 _word = ::flood_bits_down(_word);
669}
670
671/**
672 * Returns a BitMask with the bits flooded upwards.
673 */
674template<class WType, int nbits>
676flood_bits_up() const {
678 return result;
679}
680
681/**
682 * Returns a BitMask with the bits flooded down.
683 */
684template<class WType, int nbits>
686flood_bits_down() const {
688 return result;
689}
690
691
692/**
693 * Returns a BitMask with only the next highest bit above the indicated bit
694 * on, or all_off.
695 */
696template<class WType, int nbits>
698keep_next_highest_bit() const {
699 int low_bit = get_lowest_on_bit();
700 if (low_bit >= 0) {
701 return BitMask<WType, nbits>::bit(low_bit);
702 } else {
704 }
705}
706
707/**
708 * Returns a BitMask with only the next lower bit below the indicated bit on,
709 * or all_off.
710 */
711template<class WType, int nbits>
713keep_next_lowest_bit() const {
714 int high_bit = get_highest_on_bit();
715 if (high_bit >= 0) {
716 return BitMask<WType, nbits>::bit(high_bit);
717 } else {
719 }
720}
721
722/**
723 * Returns a BitMask with only the next highest bit above the indicated bit
724 * on, or all.
725 */
726template<class WType, int nbits>
728keep_next_highest_bit(int index) const {
729 BitMask<WType, nbits> mask,temp;
730 nassertr(index >= 0 && index < num_bits, mask);
731
732 mask.set_bit(index);
733 mask.flood_down_in_place();
734 mask.invert_in_place();
735 mask &= *this;
736 temp = mask;
737
738 mask <<= 1;
739 mask.flood_up_in_place();
740 mask.invert_in_place();
741 mask &= temp;
742
743 return mask;
744}
745
746/**
747 * Returns a BitMask with only the next lower bit below the indicated bit on,
748 * or all_off.
749 */
750template<class WType, int nbits>
752keep_next_lowest_bit(int index) const {
753 BitMask<WType, nbits> mask, temp;
754 nassertr(index >= 0 && index < num_bits, mask);
755
756 mask.set_bit(index);
757 mask.flood_up_in_place();
758 mask.invert_in_place();
759 mask &= *this;
760 temp = mask;
761
762 mask >>= 1;
763 mask.flood_down_in_place();
764 mask.invert_in_place();
765 mask &= temp;
766
767 return mask;
768}
769
770/**
771 * Returns a BitMask with only the next highest "on" bit above all "on" bits
772 * in the passed in bitmask, or all_off. If there are no "on" bits in the
773 * passed in bitmask, it will return keep_next_highest_bit().
774 */
775template<class WType, int nbits>
778 int high_bit = other.get_highest_on_bit();
779 if (high_bit >= 0) {
780 return keep_next_highest_bit(high_bit);
781 } else {
782 return keep_next_highest_bit();
783 }
784}
785
786/**
787 * Returns a BitMask with only the next lowest "on" bit below all "on" bits in
788 * the passed in bitmask, or all_off. If there are no "on" bits in the passed
789 * in bitmask, it will return keep_next_lowest_bit().
790 */
791template<class WType, int nbits>
794 int low_bit = other.get_lowest_on_bit();
795 if (low_bit >= 0) {
796 return keep_next_lowest_bit(low_bit);
797 } else {
798 return keep_next_lowest_bit();
799 }
800}
A general bitmask class.
Definition bitMask.h:32
void flood_up_in_place()
Floods this bitmask's bits upwards.
Definition bitMask.I:658
BitMask< WType, nbits > keep_next_highest_bit() const
Returns a BitMask with only the next highest bit above the indicated bit on, or all_off.
Definition bitMask.I:698
int get_lowest_on_bit() const
Returns the index of the lowest 1 bit in the mask.
Definition bitMask.I:283
bool has_all_of(int low_bit, int size) const
Returns true if all bits in the indicated range are set, false otherwise.
Definition bitMask.I:203
void set_range(int low_bit, int size)
Sets the indicated range of bits on.
Definition bitMask.I:213
static BitMask< WType, nbits > bit(int index)
Returns a BitMask with only the indicated bit on.
Definition bitMask.I:70
void set_bit_to(int index, bool value)
Sets the nth bit either on or off, according to the indicated bool value.
Definition bitMask.I:140
int get_highest_off_bit() const
Returns the index of the highest 0 bit in the mask.
Definition bitMask.I:313
void set_bit(int index)
Sets the nth bit on.
Definition bitMask.I:119
BitMask< WType, nbits > flood_bits_up() const
Returns a BitMask with the bits flooded upwards.
Definition bitMask.I:676
int get_highest_on_bit() const
Returns the index of the highest 1 bit in the mask.
Definition bitMask.I:303
static BitMask< WType, nbits > all_on()
Returns a BitMask whose bits are all on.
Definition bitMask.I:32
bool has_bits_in_common(const BitMask< WType, nbits > &other) const
Returns true if this BitMask has any "one" bits in common with the other one, false otherwise.
Definition bitMask.I:386
void store(WordType value, int low_bit, int size)
Stores the indicated word into the indicated range of bits with this BitMask.
Definition bitMask.I:183
bool is_all_on() const
Returns true if the entire bitmask is one, false otherwise.
Definition bitMask.I:162
static BitMask< WType, nbits > all_off()
Returns a BitMask whose bits are all off.
Definition bitMask.I:43
void output_binary(std::ostream &out, int spaces_every=4) const
Writes the BitMask out as a binary number, with spaces every four bits.
Definition bitMask.I:418
bool get_bit(int index) const
Returns true if the nth bit is set, false if it is cleared.
Definition bitMask.I:109
void set_range_to(bool value, int low_bit, int size)
Sets the indicated range of bits to either on or off.
Definition bitMask.I:233
void clear_bit(int index)
Sets the nth bit off.
Definition bitMask.I:129
int get_lowest_off_bit() const
Returns the index of the lowest 0 bit in the mask.
Definition bitMask.I:293
void generate_hash(ChecksumHashGenerator &hashgen) const
Adds the bitmask to the indicated hash generator.
Definition bitMask.I:640
void output_hex(std::ostream &out, int spaces_every=4) const
Writes the BitMask out as a hexadecimal number, with spaces every four digits.
Definition bitMask.I:433
void clear()
Sets all the bits in the BitMask off.
Definition bitMask.I:395
static BitMask< WType, nbits > range(int low_bit, int size)
Returns a BitMask whose size bits, beginning at low_bit, are on.
Definition bitMask.I:81
int get_num_on_bits() const
Returns the number of bits that are set to 1 in the mask.
Definition bitMask.I:264
BitMask< WType, nbits > keep_next_lowest_bit() const
Returns a BitMask with only the next lower bit below the indicated bit on, or all_off.
Definition bitMask.I:713
int get_key() const
Returns a mostly unique integer key per unique bitmask, suitable for using in a hash table.
Definition bitMask.I:622
void write(std::ostream &out, int indent_level=0) const
Writes the BitMask out as a binary or a hex number, according to the number of bits.
Definition bitMask.I:455
void invert_in_place()
Inverts all the bits in the BitMask.
Definition bitMask.I:372
bool __nonzero__() const
Returns true if the bitmask is not zero.
Definition bitMask.I:631
static BitMask< WType, nbits > lower_on(int on_bits)
Returns a BitMask whose lower on_bits bits are on.
Definition bitMask.I:54
void clear_range(int low_bit, int size)
Sets the indicated range of bits off.
Definition bitMask.I:223
constexpr int get_num_bits() const
Returns the number of bits available to set in the bitmask.
Definition bitMask.I:99
void set_word(WordType value)
Sets the entire BitMask to the value indicated by the given word.
Definition bitMask.I:255
int compare_to(const BitMask< WType, nbits > &other) const
Returns a number less than zero if this BitMask sorts before the indicated other BitMask,...
Definition bitMask.I:497
bool has_any_of(int low_bit, int size) const
Returns true if any bit in the indicated range is set, false otherwise.
Definition bitMask.I:193
void output(std::ostream &out) const
Writes the BitMask out as a binary or a hex number, according to the number of bits.
Definition bitMask.I:405
int get_num_off_bits() const
Returns the number of bits that are set to 0 in the mask.
Definition bitMask.I:273
bool is_zero() const
Returns true if the entire bitmask is zero, false otherwise.
Definition bitMask.I:153
WordType get_word() const
Returns the entire BitMask as a single word.
Definition bitMask.I:246
BitMask< WType, nbits > flood_bits_down() const
Returns a BitMask with the bits flooded down.
Definition bitMask.I:686
int get_next_higher_different_bit(int low_bit) const
Returns the index of the next bit in the mask, above low_bit, whose value is different that the value...
Definition bitMask.I:326
bool operator<(const BitMask< WType, nbits > &other) const
The ordering operator is of limited usefulness with a BitMask, however, it has a definition which pla...
Definition bitMask.I:486
WordType extract(int low_bit, int size) const
Returns a word that represents only the indicated range of bits within this BitMask,...
Definition bitMask.I:172
void flood_down_in_place()
Floods this bitmask's bits downwards.
Definition bitMask.I:667
This is a specific kind of HashGenerator that simply adds up all of the ints.
void add_int(long num)
Adds another integer to the hash so far.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition indent.cxx:20
int get_highest_on_bit(unsigned short x)
Returns the index of the highest 1 bit in the word.
Definition pbitops.I:259
unsigned short flood_bits_down(unsigned short x)
Returns a value such that every bit at or below the highest bit in x is 1.
Definition pbitops.I:64
unsigned short flood_bits_up(unsigned short x)
Returns a value such that every bit at or above the highest bit in x is 1.
Definition pbitops.I:119
int count_bits_in_word(unsigned short x)
Returns the number of 1 bits in the indicated word.
Definition pbitops.I:18
int get_lowest_on_bit(unsigned short x)
Returns the index of the lowest 1 bit in the word.
Definition pbitops.I:175
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...