Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

BitMask< WordType, num_bits > Class Template Reference

A general bitmask class. More...

#include <bitMask.h>

List of all members.

Public Member Functions

 BitMask ()
 BitMask (WordType init_value)
 BitMask (const BitMask< WordType, num_bits > &copy)
void operator= (const BitMask< WordType, num_bits > &copy)
 ~BitMask ()
int get_num_bits () const
 Returns the number of bits available to set in the bitmask.

bool get_bit (int index) const
 Returns true if the nth bit is set, false if it is cleared.

void set_bit (int index)
 Sets the nth bit on.

void clear_bit (int index)
 Sets the nth bit off.

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

bool is_zero () const
 Returns true if the entire bitmask is zero, false otherwise.

WordType extract (int low_bit, int size) const
 Returns a word that represents only the indicated range of bits within this BitMask, shifted to the least-significant position.

void store (WordType value, int low_bit, int size)
 Stores the indicated word into the indicated range of bits with this BitMask.

WordType get_word () const
 Returns the entire BitMask as a single word.

void set_word (WordType value)
 Sets the entire BitMask to the value indicated by the given word.

void invert_in_place ()
 Inverts all the bits in the BitMask.

void clear ()
 Sets all the bits in the BitMask off.

void output (ostream &out) const
 Writes the BitMask out as a binary or a hex number, according to the number of bits.

void output_binary (ostream &out, int spaces_every=4) const
 Writes the BitMask out as a binary number, with spaces every four bits.

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

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

bool operator== (const BitMask< WordType, num_bits > &other) const
bool operator!= (const BitMask< WordType, num_bits > &other) const
bool operator< (const BitMask< WordType, num_bits > &other) const
 The ordering operator is of limited usefulness with a BitMask, however, it has a definition which places all unique BitMasks into a unique ordering.

int compare_to (const BitMask< WordType, num_bits > &other) const
 Returns a number less than zero if this BitMask sorts before the indicated other BitMask, greater than zero if it sorts after, or 0 if they are equivalent.

BitMask< WordType, num_bits > operator & (const BitMask< WordType, num_bits > &other) const
BitMask< WordType, num_bits > operator| (const BitMask< WordType, num_bits > &other) const
BitMask< WordType, num_bits > operator^ (const BitMask< WordType, num_bits > &other) const
BitMask< WordType, num_bits > operator~ () const
BitMask< WordType, num_bits > operator<< (int shift) const
BitMask< WordType, num_bits > operator>> (int shift) const
void operator &= (const BitMask< WordType, num_bits > &other)
void operator|= (const BitMask< WordType, num_bits > &other)
void operator^= (const BitMask< WordType, num_bits > &other)
void operator<<= (int shift)
void operator>>= (int shift)
void generate_hash (ChecksumHashGenerator &hashgen) const
 Adds the bitmask to the indicated hash generator.


Static Public Member Functions

BitMask< WordType, num_bits > all_on ()
 Returns a BitMask whose bits are all on.

BitMask< WordType, num_bits > all_off ()
 Returns a BitMask whose bits are all off.

BitMask< WordType, num_bits > lower_on (int on_bits)
 Returns a BitMask whose lower num_bits bits are on.

BitMask< WordType, num_bits > bit (int index)
 Returns a BitMask with only the indicated bit on.

TypeHandle get_class_type ()
void init_type ()

Private Attributes

WordType _word

Static Private Attributes

TypeHandle _type_handle


Detailed Description

template<class WordType, int num_bits>
class BitMask< WordType, num_bits >

A general bitmask class.

This stores an array of bits of some length that must fit within a given word of the indicated type. See also BitArray.

Definition at line 46 of file bitMask.h.


Constructor & Destructor Documentation

template<class WordType, int num_bits>
BitMask< WordType, num_bits >::BitMask  )  [inline]
 

Definition at line 34 of file bitMask.I.

References INLINE.

template<class WordType, int num_bits>
BitMask< WordType, num_bits >::BitMask WordType  init_value  )  [inline]
 

Definition at line 48 of file bitMask.I.

References INLINE.

template<class WordType, int num_bits>
BitMask< WordType, num_bits >::BitMask const BitMask< WordType, num_bits > &  copy  )  [inline]
 

Definition at line 62 of file bitMask.I.

References BitMask< WordType, num_bits >::_word, and INLINE.

template<class WordType, int num_bits>
BitMask< WordType, num_bits >::~BitMask  )  [inline]
 

Definition at line 158 of file bitMask.I.

References BitMask< WordType, num_bits >::_word.


Member Function Documentation

template<class WordType, int num_bits>
BitMask< WordType, num_bits > BitMask< WordType, num_bits >::all_off  )  [inline, static]
 

Returns a BitMask whose bits are all off.

Definition at line 106 of file bitMask.I.

template<class WordType, int num_bits>
BitMask< WordType, num_bits > BitMask< WordType, num_bits >::all_on  )  [inline, static]
 

Returns a BitMask whose bits are all on.

Definition at line 90 of file bitMask.I.

template<class WordType, int num_bits>
BitMask< WordType, num_bits > BitMask< WordType, num_bits >::bit int  index  )  [inline, static]
 

Returns a BitMask with only the indicated bit on.

Definition at line 143 of file bitMask.I.

References INLINE.

template<class WordType, int num_bits>
void BitMask< WordType, num_bits >::clear void   )  [inline]
 

Sets all the bits in the BitMask off.

Definition at line 359 of file bitMask.I.

References BitMask< WordType, num_bits >::_word, and INLINE.

template<class WordType, int num_bits>
void BitMask< WordType, num_bits >::clear_bit int  index  )  [inline]
 

Sets the nth bit off.

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

Definition at line 225 of file bitMask.I.

References BitMask< WordType, num_bits >::_word, INLINE, and BitMask< WordType, num_bits >::lower_on().

Referenced by BitMask< WordType, num_bits >::get_bit().

template<class WordType, int num_bits>
int BitMask< WordType, num_bits >::compare_to const BitMask< WordType, num_bits > &  other  )  const [inline]
 

Returns a number less than zero if this BitMask sorts before the indicated other BitMask, 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 516 of file bitMask.I.

template<class WordType, int num_bits>
WordType BitMask< WordType, num_bits >::extract int  low_bit,
int  size
const [inline]
 

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

Definition at line 282 of file bitMask.I.

References BitMask< WordType, num_bits >::_word, and INLINE.

Referenced by BitMask< WordType, num_bits >::set_word().

template<class WordType, int num_bits>
void BitMask< WordType, num_bits >::generate_hash ChecksumHashGenerator hashgen  )  const [inline]
 

Adds the bitmask to the indicated hash generator.

Definition at line 691 of file bitMask.I.

template<class WordType, int num_bits>
bool BitMask< WordType, num_bits >::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, get_num_bits).

Definition at line 191 of file bitMask.I.

References BitMask< WordType, num_bits >::clear_bit(), INLINE, and BitMask< WordType, num_bits >::set_bit().

Referenced by BitMask< WordType, num_bits >::get_word().

template<class WordType, int num_bits>
TypeHandle BitMask< WordType, num_bits >::get_class_type void   )  [inline, static]
 

Definition at line 116 of file bitMask.h.

template<class WordType, int num_bits>
int BitMask< WordType, num_bits >::get_num_bits  )  const [inline]
 

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

Definition at line 173 of file bitMask.I.

template<class WordType, int num_bits>
WordType BitMask< WordType, num_bits >::get_word  )  const [inline]
 

Returns the entire BitMask as a single word.

Definition at line 315 of file bitMask.I.

References BitMask< WordType, num_bits >::get_bit().

template<class WordType, int num_bits>
void BitMask< WordType, num_bits >::init_type void   )  [static]
 

Definition at line 704 of file bitMask.I.

template<class WordType, int num_bits>
void BitMask< WordType, num_bits >::invert_in_place  )  [inline]
 

Inverts all the bits in the BitMask.

Definition at line 345 of file bitMask.I.

template<class WordType, int num_bits>
bool BitMask< WordType, num_bits >::is_zero  )  const [inline]
 

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

Definition at line 264 of file bitMask.I.

References BitMask< WordType, num_bits >::_word.

template<class WordType, int num_bits>
BitMask< WordType, num_bits > BitMask< WordType, num_bits >::lower_on int  on_bits  )  [inline, static]
 

Returns a BitMask whose lower num_bits bits are on.

Definition at line 122 of file bitMask.I.

Referenced by BitMask< WordType, num_bits >::clear_bit().

template<class WordType, int num_bits>
BitMask< WordType, num_bits > BitMask< WordType, num_bits >::operator & const BitMask< WordType, num_bits > &  other  )  const [inline]
 

Definition at line 535 of file bitMask.I.

References BitMask< WordType, num_bits >::_word, and INLINE.

template<class WordType, int num_bits>
void BitMask< WordType, num_bits >::operator &= const BitMask< WordType, num_bits > &  other  )  [inline]
 

Definition at line 625 of file bitMask.I.

template<class WordType, int num_bits>
bool BitMask< WordType, num_bits >::operator!= const BitMask< WordType, num_bits > &  other  )  const [inline]
 

Definition at line 470 of file bitMask.I.

References INLINE.

template<class WordType, int num_bits>
bool BitMask< WordType, num_bits >::operator< const BitMask< WordType, num_bits > &  other  )  const [inline]
 

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

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

Definition at line 496 of file bitMask.I.

References BitMask< WordType, num_bits >::_word, and INLINE.

template<class WordType, int num_bits>
BitMask< WordType, num_bits > BitMask< WordType, num_bits >::operator<< int  shift  )  const [inline]
 

Definition at line 595 of file bitMask.I.

template<class WordType, int num_bits>
void BitMask< WordType, num_bits >::operator<<= int  shift  )  [inline]
 

Definition at line 664 of file bitMask.I.

template<class WordType, int num_bits>
void BitMask< WordType, num_bits >::operator= const BitMask< WordType, num_bits > &  copy  )  [inline]
 

Definition at line 76 of file bitMask.I.

References BitMask< WordType, num_bits >::_word.

template<class WordType, int num_bits>
bool BitMask< WordType, num_bits >::operator== const BitMask< WordType, num_bits > &  other  )  const [inline]
 

Definition at line 457 of file bitMask.I.

References BitMask< WordType, num_bits >::_word, and INLINE.

template<class WordType, int num_bits>
BitMask< WordType, num_bits > BitMask< WordType, num_bits >::operator>> int  shift  )  const [inline]
 

Definition at line 610 of file bitMask.I.

template<class WordType, int num_bits>
void BitMask< WordType, num_bits >::operator>>= int  shift  )  [inline]
 

Definition at line 677 of file bitMask.I.

template<class WordType, int num_bits>
BitMask< WordType, num_bits > BitMask< WordType, num_bits >::operator^ const BitMask< WordType, num_bits > &  other  )  const [inline]
 

Definition at line 565 of file bitMask.I.

References BitMask< WordType, num_bits >::_type_handle, register_type(), and ostringstream::str().

template<class WordType, int num_bits>
void BitMask< WordType, num_bits >::operator^= const BitMask< WordType, num_bits > &  other  )  [inline]
 

Definition at line 651 of file bitMask.I.

template<class WordType, int num_bits>
BitMask< WordType, num_bits > BitMask< WordType, num_bits >::operator| const BitMask< WordType, num_bits > &  other  )  const [inline]
 

Definition at line 550 of file bitMask.I.

References BitMask< WordType, num_bits >::_word, ChecksumHashGenerator::add_int(), and INLINE.

template<class WordType, int num_bits>
void BitMask< WordType, num_bits >::operator|= const BitMask< WordType, num_bits > &  other  )  [inline]
 

Definition at line 638 of file bitMask.I.

template<class WordType, int num_bits>
BitMask< WordType, num_bits > BitMask< WordType, num_bits >::operator~  )  const [inline]
 

Definition at line 580 of file bitMask.I.

template<class WordType, int num_bits>
void BitMask< WordType, num_bits >::output ostream &  out  )  const
 

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

Definition at line 375 of file bitMask.I.

References BitMask< WordType, num_bits >::_word, and INLINE.

template<class WordType, int num_bits>
void BitMask< WordType, num_bits >::output_binary ostream &  out,
int  spaces_every = 4
const
 

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

Definition at line 395 of file bitMask.I.

References BitMask< WordType, num_bits >::_word.

template<class WordType, int num_bits>
void BitMask< WordType, num_bits >::output_hex ostream &  out,
int  spaces_every = 4
const
 

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

Definition at line 416 of file bitMask.I.

Referenced by BitMask< WordType, num_bits >::store().

template<class WordType, int num_bits>
void BitMask< WordType, num_bits >::set_bit int  index  )  [inline]
 

Sets the nth bit on.

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

Definition at line 208 of file bitMask.I.

References BitMask< WordType, num_bits >::_word, and INLINE.

Referenced by BitMask< WordType, num_bits >::get_bit().

template<class WordType, int num_bits>
void BitMask< WordType, num_bits >::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, get_num_bits).

Definition at line 244 of file bitMask.I.

References BitMask< WordType, num_bits >::_word, and INLINE.

template<class WordType, int num_bits>
void BitMask< WordType, num_bits >::set_word WordType  value  )  [inline]
 

Sets the entire BitMask to the value indicated by the given word.

Definition at line 331 of file bitMask.I.

References BitMask< WordType, num_bits >::extract().

template<class WordType, int num_bits>
void BitMask< WordType, num_bits >::store WordType  value,
int  low_bit,
int  size
[inline]
 

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

Definition at line 299 of file bitMask.I.

References BitMask< WordType, num_bits >::output_hex().

template<class WordType, int num_bits>
void BitMask< WordType, num_bits >::write 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 at line 444 of file bitMask.I.

References INLINE.


Member Data Documentation

template<class WordType, int num_bits>
TypeHandle BitMask< WordType, num_bits >::_type_handle [static, private]
 

Definition at line 23 of file bitMask.I.

Referenced by BitMask< WordType, num_bits >::operator^().

template<class WordType, int num_bits>
WordType BitMask< WordType, num_bits >::_word [private]
 

Definition at line 113 of file bitMask.h.

Referenced by BitMask< WordType, num_bits >::BitMask(), BitMask< WordType, num_bits >::clear(), BitMask< WordType, num_bits >::clear_bit(), BitMask< WordType, num_bits >::extract(), BitMask< WordType, num_bits >::is_zero(), BitMask< WordType, num_bits >::operator &(), BitMask< WordType, num_bits >::operator<(), BitMask< WordType, num_bits >::operator=(), BitMask< WordType, num_bits >::operator==(), BitMask< WordType, num_bits >::operator|(), BitMask< WordType, num_bits >::output(), BitMask< WordType, num_bits >::output_binary(), BitMask< WordType, num_bits >::set_bit(), BitMask< WordType, num_bits >::set_bit_to(), and BitMask< WordType, num_bits >::~BitMask().


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:47:44 2003 for Panda by doxygen1.3