LSSTApplications  1.1.2+25,10.0+13,10.0+132,10.0+133,10.0+224,10.0+41,10.0+8,10.0-1-g0f53050+14,10.0-1-g4b7b172+19,10.0-1-g61a5bae+98,10.0-1-g7408a83+3,10.0-1-gc1e0f5a+19,10.0-1-gdb4482e+14,10.0-11-g3947115+2,10.0-12-g8719d8b+2,10.0-15-ga3f480f+1,10.0-2-g4f67435,10.0-2-gcb4bc6c+26,10.0-28-gf7f57a9+1,10.0-3-g1bbe32c+14,10.0-3-g5b46d21,10.0-4-g027f45f+5,10.0-4-g86f66b5+2,10.0-4-gc4fccf3+24,10.0-40-g4349866+2,10.0-5-g766159b,10.0-5-gca2295e+25,10.0-6-g462a451+1
LSSTDataManagementBasePackage
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
lsst::ap::Bitset< WordT, NumBits > Class Template Reference

A fixed size set of bits. More...

#include <Bitset.h>

Public Member Functions

void reset ()
 
void set ()
 
void reset (int const i)
 
void set (int const i)
 
void set (int const i, bool const on)
 
bool test (int const i) const
 
bool set (int *const indexes, int const numBits)
 
void reset (int const *const indexes, int const numBits)
 

Static Public Attributes

static int const NUM_BITS = NumBits
 
static int const NUM_WORDS
 

Private Member Functions

 BOOST_STATIC_ASSERT (NumBits > 0)
 
 BOOST_STATIC_ASSERT (detail::BitTraits< WordT >::IS_SPECIALIZED)
 

Private Attributes

WordT _bits [NUM_WORDS]
 

Detailed Description

template<typename WordT, int NumBits>
class lsst::ap::Bitset< WordT, NumBits >

A fixed size set of bits.

Definition at line 109 of file Bitset.h.

Member Function Documentation

template<typename WordT, int NumBits>
lsst::ap::Bitset< WordT, NumBits >::BOOST_STATIC_ASSERT ( NumBits  ,
 
)
private
template<typename WordT, int NumBits>
lsst::ap::Bitset< WordT, NumBits >::BOOST_STATIC_ASSERT ( detail::BitTraits< WordT >::IS_SPECIALIZED  )
private
template<typename WordT, int NumBits>
void lsst::ap::Bitset< WordT, NumBits >::reset ( )
inline

Clears all bits.

Definition at line 123 of file Bitset.h.

123  {
124  std::memset(_bits, 0, sizeof(_bits));
125  }
WordT _bits[NUM_WORDS]
Definition: Bitset.h:174
template<typename WordT, int NumBits>
void lsst::ap::Bitset< WordT, NumBits >::reset ( int const  i)
inline

Sets the i-th bit in the set to zero.

Definition at line 133 of file Bitset.h.

133  {
134  assert(i >= 0 && i < NumBits);
135  _bits[detail::wordForBit<WordT>(i)] &= ~ detail::maskForBit<WordT>(i);
136  }
WordT _bits[NUM_WORDS]
Definition: Bitset.h:174
template<typename WordT, int NumBits>
void lsst::ap::Bitset< WordT, NumBits >::reset ( int const *const  indexes,
int const  numBits 
)
inline

Sets numBits bits identified by the integers in indexes to zero.

Definition at line 168 of file Bitset.h.

168  {
169  detail::resetBits<WordT>(_bits, indexes, numBits, NumBits);
170  }
WordT _bits[NUM_WORDS]
Definition: Bitset.h:174
template<typename WordT, int NumBits>
void lsst::ap::Bitset< WordT, NumBits >::set ( )
inline

Sets all bits to 1.

Definition at line 128 of file Bitset.h.

128  {
129  std::memset(_bits, -1, sizeof(_bits));
130  }
WordT _bits[NUM_WORDS]
Definition: Bitset.h:174
template<typename WordT, int NumBits>
void lsst::ap::Bitset< WordT, NumBits >::set ( int const  i)
inline

Sets the i-th bit in the set to one.

Definition at line 139 of file Bitset.h.

139  {
140  assert(i >= 0 && i < NumBits);
141  _bits[detail::wordForBit<WordT>(i)] |= detail::maskForBit<WordT>(i);
142  }
WordT _bits[NUM_WORDS]
Definition: Bitset.h:174
template<typename WordT, int NumBits>
void lsst::ap::Bitset< WordT, NumBits >::set ( int const  i,
bool const  on 
)
inline

Sets the i-th bit in the set to one if on is true and to zero otherwise.

Definition at line 145 of file Bitset.h.

145  {
146  if (on) {
147  set(i);
148  } else {
149  reset(i);
150  }
151  }
void reset()
Definition: Bitset.h:123
void set()
Definition: Bitset.h:128
template<typename WordT, int NumBits>
bool lsst::ap::Bitset< WordT, NumBits >::set ( int *const  indexes,
int const  numBits 
)
inline

If at least numBits zero bits are available in this Bitset, this function sets the first numBits of them to one and returns true. Otherwise, false is returned.

Definition at line 163 of file Bitset.h.

163  {
164  return detail::setBits<WordT>(indexes, _bits, numBits, NumBits);
165  }
WordT _bits[NUM_WORDS]
Definition: Bitset.h:174
template<typename WordT, int NumBits>
bool lsst::ap::Bitset< WordT, NumBits >::test ( int const  i) const
inline

Returns true if the i-th bit in the set is one and false otherwise.

Definition at line 154 of file Bitset.h.

154  {
155  assert(i >= 0 && i < NumBits);
156  return _bits[detail::wordForBit<WordT>(i)] & detail::maskForBit<WordT>(i);
157  }
WordT _bits[NUM_WORDS]
Definition: Bitset.h:174

Member Data Documentation

template<typename WordT, int NumBits>
WordT lsst::ap::Bitset< WordT, NumBits >::_bits[NUM_WORDS]
private

Definition at line 174 of file Bitset.h.

template<typename WordT, int NumBits>
int const lsst::ap::Bitset< WordT, NumBits >::NUM_BITS = NumBits
static

Definition at line 118 of file Bitset.h.

template<typename WordT, int NumBits>
int const lsst::ap::Bitset< WordT, NumBits >::NUM_WORDS
static
Initial value:
= (NumBits + (detail::BitTraits<WordT>::BITS_PER_WORD - 1)) >>
detail::BitTraits<WordT>::BITS_PER_WORD_LOG2

Definition at line 119 of file Bitset.h.


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