Panda3D
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. More...
 
void clear_bit (int index)
 Sets the nth bit off. More...
 
void clear_range (int low_bit, int size)
 Sets the indicated range of bits off. More...
 
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. More...
 
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. More...
 
void generate_hash (ChecksumHashGenerator &hashgen) const
 Adds the doubleBitMask to the indicated hash generator. More...
 
bool get_bit (int index) const
 Returns true if the nth bit is set, false if it is cleared. More...
 
int get_highest_off_bit () const
 Returns the index of the highest 0 bit in the mask. More...
 
int get_highest_on_bit () const
 Returns the index of the highest 1 bit in the mask. More...
 
int get_lowest_off_bit () const
 Returns the index of the lowest 0 bit in the mask. More...
 
int get_lowest_on_bit () const
 Returns the index of the lowest 1 bit in the mask. More...
 
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. More...
 
constexpr int get_num_bits () const
 Returns the number of bits available to set in the doubleBitMask. More...
 
int get_num_off_bits () const
 Returns the number of bits that are set to 0 in the mask. More...
 
int get_num_on_bits () const
 Returns the number of bits that are set to 1 in the mask. More...
 
bool has_all_of (int low_bit, int size) const
 Returns true if all bits in the indicated range are set, false otherwise. More...
 
bool has_any_of (int low_bit, int size) const
 Returns true if any bit in the indicated range is set, false otherwise. More...
 
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. More...
 
void invert_in_place ()
 Inverts all the bits in the DoubleBitMask. More...
 
bool is_all_on () const
 Returns true if the entire doubleBitMask is one, false otherwise. More...
 
bool is_zero () const
 Returns true if the entire doubleBitMask is zero, false otherwise. More...
 
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. More...
 
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. More...
 
void output_binary (std::ostream &out, int spaces_every=4) const
 Writes the DoubleBitMask out as a binary number, with spaces every four bits. More...
 
void output_hex (std::ostream &out, int spaces_every=4) const
 Writes the DoubleBitMask out as a hexadecimal number, with spaces every four digits. More...
 
void set_bit (int index)
 Sets the nth bit on. More...
 
void set_bit_to (int index, bool value)
 Sets the nth bit either on or off, according to the indicated bool value. More...
 
void set_range (int low_bit, int size)
 Sets the indicated range of bits on. More...
 
void set_range_to (bool value, int low_bit, int size)
 Sets the indicated range of bits to either on or off. More...
 
void store (WordType value, int low_bit, int size)
 Stores the indicated word into the indicated range of bits with this DoubleBitMask. More...
 
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. More...
 

Static Public Member Functions

static DoubleBitMask< BMType > all_off ()
 Returns a DoubleBitMask whose bits are all off. More...
 
static DoubleBitMask< BMType > all_on ()
 Returns a DoubleBitMask whose bits are all on. More...
 
static DoubleBitMask< BMType > bit (int index)
 Returns a DoubleBitMask with only the indicated bit on. More...
 
static TypeHandle get_class_type ()
 
constexpr static int get_max_num_bits ()
 
constexpr static 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. More...
 
static DoubleBitMask< BMType > range (int low_bit, int size)
 Returns a DoubleBitMask whose size bits, beginning at low_bit, are on. More...
 

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

◆ 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_highest_off_bit()

template<class BMType >
int DoubleBitMask< BMType >::get_highest_off_bit
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
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
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
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_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
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
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
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.

◆ 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
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
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

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.

◆ 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.

◆ 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.

◆ 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.

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


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