CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Attributes | Friends
PhysicsTools::BitSet::Iterator Class Reference

Iterates over all set bits of a BitSet. More...

#include <BitSet.h>

Public Member Functions

 operator bool () const
 boolean test for the end of the BitSet More...
 
size_t operator() () const
 returns the index of the currently pointed-at bit More...
 
Iteratoroperator++ ()
 increment iterator to point at the next set bit More...
 
Iterator operator++ (int dummy)
 increment iterator to point at the next set bit More...
 

Protected Member Functions

 Iterator (Word_t *begin, Word_t *end)
 

Private Attributes

Word_tbegin
 
Word_tend
 
unsigned int pos
 
Word_tstore
 

Friends

class BitSet
 

Detailed Description

Iterates over all set bits of a BitSet.

This structure is used to iterate over all set bits in a BitSet.

Definition at line 78 of file BitSet.h.

Constructor & Destructor Documentation

PhysicsTools::BitSet::Iterator::Iterator ( Word_t begin,
Word_t end 
)
inlineprotected

Definition at line 118 of file BitSet.h.

References store.

118  :
119  begin(begin), store(begin), end(end), pos(0)
120  { if (store < end && !(*store & 1)) ++*this; }

Member Function Documentation

PhysicsTools::BitSet::Iterator::operator bool ( ) const
inline

boolean test for the end of the BitSet

Definition at line 81 of file BitSet.h.

References end, and store.

81 { return store < end; }
size_t PhysicsTools::BitSet::Iterator::operator() ( ) const
inline

returns the index of the currently pointed-at bit

Definition at line 84 of file BitSet.h.

References begin, pos, store, and PhysicsTools::BitSet::wordSize.

85  { return (store - begin) * wordSize + pos; }
static const unsigned int wordSize
Definition: BitSet.h:187
Iterator& PhysicsTools::BitSet::Iterator::operator++ ( void  )
inline

increment iterator to point at the next set bit

Definition at line 88 of file BitSet.h.

References end, pos, store, and PhysicsTools::BitSet::wordSize.

89  {
90  if (++pos < wordSize) {
91  Word_t word = *store & -(1 << pos);
92  if (word) {
93  pos = ffs(word) - 1;
94  return *this;
95  }
96  }
97 
98  pos = 0;
99  for(;;) {
100  if (++store >= end)
101  break;
102  else if (*store) {
103  pos = ffs(*store) - 1;
104  break;
105  }
106  }
107 
108  return *this;
109  }
unsigned int Word_t
Definition: BitSet.h:35
static const unsigned int wordSize
Definition: BitSet.h:187
Iterator PhysicsTools::BitSet::Iterator::operator++ ( int  dummy)
inline

increment iterator to point at the next set bit

Definition at line 112 of file BitSet.h.

113  { Iterator orig = *this; ++*this; return orig; }

Friends And Related Function Documentation

friend class BitSet
friend

Definition at line 116 of file BitSet.h.

Member Data Documentation

Word_t* PhysicsTools::BitSet::Iterator::begin
private

Definition at line 123 of file BitSet.h.

Referenced by operator()().

Word_t * PhysicsTools::BitSet::Iterator::end
private
unsigned int PhysicsTools::BitSet::Iterator::pos
private
Word_t * PhysicsTools::BitSet::Iterator::store
private

Definition at line 123 of file BitSet.h.

Referenced by Iterator(), operator bool(), operator()(), and operator++().