Panda3D
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
DoubleBitMask< BMType > Class Template Reference

This is a special BitMask type that is implemented as a pair of lesser BitMask types, to present a double-wide bit mask. More...

#include "doubleBitMask.h"

Public Types

enum  { half_bits = BMType::num_bits , num_bits = BMType::num_bits * 2 }
 
typedef BMType BitMaskType
 
typedef BMType::WordType WordType
 

Public Member Functions

void clear ()
 Sets all the bits in the DoubleBitMask off.
 
void clear_bit (int index)
 Sets the nth bit off.
 
void clear_range (int low_bit, int size)
 Sets the indicated range of bits off.
 
int compare_to (const DoubleBitMask< BMType > &other) const
 Returns a number less than zero if this DoubleBitMask sorts before the indicated other DoubleBitMask, greater than zero if it sorts after, or 0 if they are equivalent.
 
WordType extract (int low_bit, int size) const
 Returns a word that represents only the indicated range of bits within this DoubleBitMask, shifted to the least-significant position.
 
void generate_hash (ChecksumHashGenerator &hashgen) const
 Adds the doubleBitMask to the indicated hash generator.
 
bool get_bit (int index) const
 Returns true if the nth bit is set, false if it is cleared.
 
int get_highest_off_bit () const
 Returns the index of the highest 0 bit in the mask.
 
int get_highest_on_bit () const
 Returns the index of the highest 1 bit in the mask.
 
int get_lowest_off_bit () const
 Returns the index of the lowest 0 bit in the mask.
 
int get_lowest_on_bit () const
 Returns the index of the lowest 1 bit in the mask.
 
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 of low_bit.
 
constexpr int get_num_bits () const
 Returns the number of bits available to set in the doubleBitMask.
 
int get_num_off_bits () const
 Returns the number of bits that are set to 0 in the mask.
 
int get_num_on_bits () const
 Returns the number of bits that are set to 1 in the mask.
 
bool has_all_of (int low_bit, int size) const
 Returns true if all bits in the indicated range are set, false otherwise.
 
bool has_any_of (int low_bit, int size) const
 Returns true if any bit in the indicated range is set, false otherwise.
 
bool has_bits_in_common (const DoubleBitMask< BMType > &other) const
 Returns true if this DoubleBitMask has any "one" bits in common with the other one, false otherwise.
 
void invert_in_place ()
 Inverts all the bits in the DoubleBitMask.
 
bool is_all_on () const
 Returns true if the entire doubleBitMask is one, false otherwise.
 
bool is_zero () const
 Returns true if the entire doubleBitMask is zero, false otherwise.
 
bool operator!= (const DoubleBitMask< BMType > &other) const
 
DoubleBitMask< BMType > operator& (const DoubleBitMask< BMType > &other) const
 
void operator&= (const DoubleBitMask< BMType > &other)
 
bool operator< (const DoubleBitMask< BMType > &other) const
 The ordering operator is of limited usefulness with a DoubleBitMask, however, it has a definition which places all unique DoubleBitMasks into a unique ordering.
 
DoubleBitMask< BMType > operator<< (int shift) const
 
void operator<<= (int shift)
 
bool operator== (const DoubleBitMask< BMType > &other) const
 
DoubleBitMask< BMType > operator>> (int shift) const
 
void operator>>= (int shift)
 
DoubleBitMask< BMType > operator^ (const DoubleBitMask< BMType > &other) const
 
void operator^= (const DoubleBitMask< BMType > &other)
 
DoubleBitMask< BMType > operator| (const DoubleBitMask< BMType > &other) const
 
void operator|= (const DoubleBitMask< BMType > &other)
 
DoubleBitMask< BMType > operator~ () const
 
void output (std::ostream &out) const
 Writes the DoubleBitMask out as a binary or a hex number, according to the number of bits.
 
void output_binary (std::ostream &out, int spaces_every=4) const
 Writes the DoubleBitMask out as a binary number, with spaces every four bits.
 
void output_hex (std::ostream &out, int spaces_every=4) const
 Writes the DoubleBitMask out as a hexadecimal number, with spaces every four digits.
 
void set_bit (int index)
 Sets the nth bit on.
 
void set_bit_to (int index, bool value)
 Sets the nth bit either on or off, according to the indicated bool value.
 
void set_range (int low_bit, int size)
 Sets the indicated range of bits 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 DoubleBitMask.
 
void write (std::ostream &out, int indent_level=0) const
 Writes the DoubleBitMask out as a binary or a hex number, according to the number of bits.
 

Static Public Member Functions

static DoubleBitMask< BMType > all_off ()
 Returns a DoubleBitMask whose bits are all off.
 
static DoubleBitMask< BMType > all_on ()
 Returns a DoubleBitMask whose bits are all on.
 
static DoubleBitMask< BMType > bit (int index)
 Returns a DoubleBitMask with only the indicated bit on.
 
static TypeHandle get_class_type ()
 
static constexpr int get_max_num_bits ()
 
static constexpr bool has_max_num_bits ()
 
static void init_type ()
 
static DoubleBitMask< BMType > lower_on (int on_bits)
 Returns a DoubleBitMask whose lower on_bits bits are on.
 
static DoubleBitMask< BMType > range (int low_bit, int size)
 Returns a DoubleBitMask whose size bits, beginning at low_bit, are on.
 

Friends

class Extension< DoubleBitMask >
 

Detailed Description

template<class BMType>
class DoubleBitMask< BMType >

This is a special BitMask type that is implemented as a pair of lesser BitMask types, to present a double-wide bit mask.

For instance, on a 32-bit system, this can be used to make a single 64-bit bit mask. More of these can be ganged up together to make a 128-bit mask, and so on.

Definition at line 29 of file doubleBitMask.h.

Member Typedef Documentation

◆ BitMaskType

template<class BMType >
typedef BMType DoubleBitMask< BMType >::BitMaskType

Definition at line 34 of file doubleBitMask.h.

◆ WordType

template<class BMType >
typedef BMType::WordType DoubleBitMask< BMType >::WordType

Definition at line 31 of file doubleBitMask.h.

Member Enumeration Documentation

◆ anonymous enum

template<class BMType >
anonymous enum

Definition at line 36 of file doubleBitMask.h.

Member Function Documentation

◆ all_off()

template<class BMType >
DoubleBitMask< BMType > DoubleBitMask< BMType >::all_off ( )
inlinestatic

Returns a DoubleBitMask whose bits are all off.

Definition at line 33 of file doubleBitMask.I.

◆ all_on()

template<class BMType >
DoubleBitMask< BMType > DoubleBitMask< BMType >::all_on ( )
inlinestatic

Returns a DoubleBitMask whose bits are all on.

Definition at line 21 of file doubleBitMask.I.

◆ bit()

template<class BMType >
DoubleBitMask< BMType > DoubleBitMask< BMType >::bit ( int index)
inlinestatic

Returns a DoubleBitMask with only the indicated bit on.

Definition at line 66 of file doubleBitMask.I.

References DoubleBitMask< BMType >::set_bit().

◆ clear()

template<class BMType >
void DoubleBitMask< BMType >::clear ( )
inline

Sets all the bits in the DoubleBitMask off.

Definition at line 433 of file doubleBitMask.I.

◆ clear_bit()

template<class BMType >
void DoubleBitMask< BMType >::clear_bit ( int index)
inline

Sets the nth bit off.

index must be in the range [0, num_bits).

Definition at line 124 of file doubleBitMask.I.

◆ clear_range()

template<class BMType >
void DoubleBitMask< BMType >::clear_range ( int low_bit,
int size )
inline

Sets the indicated range of bits off.

Definition at line 263 of file doubleBitMask.I.

◆ compare_to()

template<class BMType >
int DoubleBitMask< BMType >::compare_to ( const DoubleBitMask< BMType > & other) const
inline

Returns a number less than zero if this DoubleBitMask sorts before the indicated other DoubleBitMask, greater than zero if it sorts after, or 0 if they are equivalent.

This is based on the same ordering defined by operator <.

Definition at line 525 of file doubleBitMask.I.

◆ extract()

template<class BMType >
DoubleBitMask< BMType >::WordType DoubleBitMask< BMType >::extract ( int low_bit,
int size ) const
inline

Returns a word that represents only the indicated range of bits within this DoubleBitMask, shifted to the least-significant position.

Definition at line 170 of file doubleBitMask.I.

◆ generate_hash()

template<class BMType >
void DoubleBitMask< BMType >::generate_hash ( ChecksumHashGenerator & hashgen) const
inline

Adds the doubleBitMask to the indicated hash generator.

Definition at line 654 of file doubleBitMask.I.

◆ get_bit()

template<class BMType >
bool DoubleBitMask< BMType >::get_bit ( int index) const
inline

Returns true if the nth bit is set, false if it is cleared.

index must be in the range [0, num_bits).

Definition at line 98 of file doubleBitMask.I.

◆ get_class_type()

template<class BMType >
static TypeHandle DoubleBitMask< BMType >::get_class_type ( )
inlinestatic

Definition at line 126 of file doubleBitMask.h.

◆ get_highest_off_bit()

template<class BMType >
int DoubleBitMask< BMType >::get_highest_off_bit ( ) const
inline

Returns the index of the highest 0 bit in the mask.

Returns -1 if there are no 0 bits.

Definition at line 364 of file doubleBitMask.I.

◆ get_highest_on_bit()

template<class BMType >
int DoubleBitMask< BMType >::get_highest_on_bit ( ) const
inline

Returns the index of the highest 1 bit in the mask.

Returns -1 if there are no 1 bits.

Definition at line 348 of file doubleBitMask.I.

◆ get_lowest_off_bit()

template<class BMType >
int DoubleBitMask< BMType >::get_lowest_off_bit ( ) const
inline

Returns the index of the lowest 0 bit in the mask.

Returns -1 if there are no 0 bits.

Definition at line 331 of file doubleBitMask.I.

◆ get_lowest_on_bit()

template<class BMType >
int DoubleBitMask< BMType >::get_lowest_on_bit ( ) const
inline

Returns the index of the lowest 1 bit in the mask.

Returns -1 if there are no 1 bits.

Definition at line 314 of file doubleBitMask.I.

◆ get_max_num_bits()

template<class BMType >
static constexpr int DoubleBitMask< BMType >::get_max_num_bits ( )
inlinestaticconstexpr

Definition at line 51 of file doubleBitMask.h.

◆ get_next_higher_different_bit()

template<class BMType >
int DoubleBitMask< BMType >::get_next_higher_different_bit ( int low_bit) const
inline

Returns the index of the next bit in the mask, 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 mask.

Definition at line 383 of file doubleBitMask.I.

◆ get_num_bits()

template<class BMType >
constexpr int DoubleBitMask< BMType >::get_num_bits ( ) const
constexpr

Returns the number of bits available to set in the doubleBitMask.

Definition at line 88 of file doubleBitMask.I.

◆ get_num_off_bits()

template<class BMType >
int DoubleBitMask< BMType >::get_num_off_bits ( ) const
inline

Returns the number of bits that are set to 0 in the mask.

Definition at line 304 of file doubleBitMask.I.

◆ get_num_on_bits()

template<class BMType >
int DoubleBitMask< BMType >::get_num_on_bits ( ) const
inline

Returns the number of bits that are set to 1 in the mask.

Definition at line 295 of file doubleBitMask.I.

◆ has_all_of()

template<class BMType >
bool DoubleBitMask< BMType >::has_all_of ( int low_bit,
int size ) const
inline

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

Definition at line 226 of file doubleBitMask.I.

◆ has_any_of()

template<class BMType >
bool DoubleBitMask< BMType >::has_any_of ( int low_bit,
int size ) const
inline

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

Definition at line 208 of file doubleBitMask.I.

◆ has_bits_in_common()

template<class BMType >
bool DoubleBitMask< BMType >::has_bits_in_common ( const DoubleBitMask< BMType > & other) const
inline

Returns true if this DoubleBitMask has any "one" bits in common with the other one, false otherwise.

This is equivalent to (mask & other) != 0, but may be faster. (Actually, it should only be faster in the BitArray case, but this method is provided for the benefit of generic programming algorithms).

Definition at line 423 of file doubleBitMask.I.

◆ has_max_num_bits()

template<class BMType >
static constexpr bool DoubleBitMask< BMType >::has_max_num_bits ( )
inlinestaticconstexpr

Definition at line 50 of file doubleBitMask.h.

◆ init_type()

template<class BMType >
void DoubleBitMask< BMType >::init_type ( )
static

Definition at line 664 of file doubleBitMask.I.

◆ invert_in_place()

template<class BMType >
void DoubleBitMask< BMType >::invert_in_place ( )
inline

Inverts all the bits in the DoubleBitMask.

This is equivalent to mask = ~mask.

Definition at line 408 of file doubleBitMask.I.

◆ is_all_on()

template<class BMType >
bool DoubleBitMask< BMType >::is_all_on ( ) const
inline

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

Definition at line 160 of file doubleBitMask.I.

◆ is_zero()

template<class BMType >
bool DoubleBitMask< BMType >::is_zero ( ) const
inline

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

Definition at line 151 of file doubleBitMask.I.

◆ lower_on()

template<class BMType >
DoubleBitMask< BMType > DoubleBitMask< BMType >::lower_on ( int on_bits)
inlinestatic

Returns a DoubleBitMask whose lower on_bits bits are on.

Definition at line 45 of file doubleBitMask.I.

◆ operator!=()

template<class BMType >
bool DoubleBitMask< BMType >::operator!= ( const DoubleBitMask< BMType > & other) const
inline

Definition at line 496 of file doubleBitMask.I.

◆ operator&()

template<class BMType >
DoubleBitMask< BMType > DoubleBitMask< BMType >::operator& ( const DoubleBitMask< BMType > & other) const
inline

Definition at line 538 of file doubleBitMask.I.

◆ operator&=()

template<class BMType >
void DoubleBitMask< BMType >::operator&= ( const DoubleBitMask< BMType > & other)
inline

Definition at line 604 of file doubleBitMask.I.

◆ operator<()

template<class BMType >
bool DoubleBitMask< BMType >::operator< ( const DoubleBitMask< BMType > & other) const
inline

The ordering operator is of limited usefulness with a DoubleBitMask, however, it has a definition which places all unique DoubleBitMasks into a unique ordering.

It may be useful when defining ordered STL containers of DoubleBitMasks, for instance; and it's required in order to export any STL container (ordered or unordered) of DoubleBitMask under Windows.

Definition at line 509 of file doubleBitMask.I.

◆ operator<<()

template<class BMType >
DoubleBitMask< BMType > DoubleBitMask< BMType >::operator<< ( int shift) const
inline

Definition at line 571 of file doubleBitMask.I.

◆ operator<<=()

template<class BMType >
void DoubleBitMask< BMType >::operator<<= ( int shift)
inline

Definition at line 634 of file doubleBitMask.I.

◆ operator==()

template<class BMType >
bool DoubleBitMask< BMType >::operator== ( const DoubleBitMask< BMType > & other) const
inline

Definition at line 487 of file doubleBitMask.I.

◆ operator>>()

template<class BMType >
DoubleBitMask< BMType > DoubleBitMask< BMType >::operator>> ( int shift) const
inline

Definition at line 593 of file doubleBitMask.I.

◆ operator>>=()

template<class BMType >
void DoubleBitMask< BMType >::operator>>= ( int shift)
inline

Definition at line 644 of file doubleBitMask.I.

◆ operator^()

template<class BMType >
DoubleBitMask< BMType > DoubleBitMask< BMType >::operator^ ( const DoubleBitMask< BMType > & other) const
inline

Definition at line 560 of file doubleBitMask.I.

◆ operator^=()

template<class BMType >
void DoubleBitMask< BMType >::operator^= ( const DoubleBitMask< BMType > & other)
inline

Definition at line 624 of file doubleBitMask.I.

◆ operator|()

template<class BMType >
DoubleBitMask< BMType > DoubleBitMask< BMType >::operator| ( const DoubleBitMask< BMType > & other) const
inline

Definition at line 549 of file doubleBitMask.I.

◆ operator|=()

template<class BMType >
void DoubleBitMask< BMType >::operator|= ( const DoubleBitMask< BMType > & other)
inline

Definition at line 614 of file doubleBitMask.I.

◆ operator~()

template<class BMType >
DoubleBitMask< BMType > DoubleBitMask< BMType >::operator~ ( ) const
inline

Definition at line 571 of file doubleBitMask.I.

◆ output()

template<class BMType >
void DoubleBitMask< BMType >::output ( std::ostream & out) const

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

Definition at line 444 of file doubleBitMask.I.

◆ output_binary()

template<class BMType >
void DoubleBitMask< BMType >::output_binary ( std::ostream & out,
int spaces_every = 4 ) const

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

Definition at line 454 of file doubleBitMask.I.

◆ output_hex()

template<class BMType >
void DoubleBitMask< BMType >::output_hex ( std::ostream & out,
int spaces_every = 4 ) const

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

Definition at line 466 of file doubleBitMask.I.

◆ range()

template<class BMType >
DoubleBitMask< BMType > DoubleBitMask< BMType >::range ( int low_bit,
int size )
inlinestatic

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

Definition at line 77 of file doubleBitMask.I.

References DoubleBitMask< BMType >::set_range().

◆ set_bit()

template<class BMType >
void DoubleBitMask< BMType >::set_bit ( int index)
inline

Sets the nth bit on.

index must be in the range [0, num_bits).

Definition at line 111 of file doubleBitMask.I.

Referenced by DoubleBitMask< BMType >::bit().

◆ set_bit_to()

template<class BMType >
void DoubleBitMask< BMType >::set_bit_to ( int index,
bool value )
inline

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

index must be in the range [0, num_bits).

Definition at line 138 of file doubleBitMask.I.

◆ set_range()

template<class BMType >
void DoubleBitMask< BMType >::set_range ( int low_bit,
int size )
inline

Sets the indicated range of bits on.

Definition at line 244 of file doubleBitMask.I.

Referenced by DoubleBitMask< BMType >::range().

◆ set_range_to()

template<class BMType >
void DoubleBitMask< BMType >::set_range_to ( bool value,
int low_bit,
int size )
inline

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

Definition at line 282 of file doubleBitMask.I.

◆ store()

template<class BMType >
void DoubleBitMask< BMType >::store ( WordType value,
int low_bit,
int size )
inline

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

Definition at line 189 of file doubleBitMask.I.

◆ write()

template<class BMType >
void DoubleBitMask< BMType >::write ( std::ostream & out,
int indent_level = 0 ) const

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

Definition at line 478 of file doubleBitMask.I.

References indent().

Friends And Related Symbol Documentation

◆ Extension< DoubleBitMask >

template<class BMType >
friend class Extension< DoubleBitMask >
friend

Definition at line 121 of file doubleBitMask.h.


The documentation for this class was generated from the following files: