CMS 3D CMS Logo

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 77 of file BitSet.h.

Constructor & Destructor Documentation

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

Definition at line 117 of file BitSet.h.

References PhysicsTools::BitSet::store.

117  :
118  begin(begin), store(begin), end(end), pos(0)
119  { 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 80 of file BitSet.h.

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

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

returns the index of the currently pointed-at bit

Definition at line 83 of file BitSet.h.

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

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

increment iterator to point at the next set bit

Definition at line 87 of file BitSet.h.

References end, PhysicsTools::BitSet::store, PhysicsTools::BitSet::Manipulator::word, and PhysicsTools::BitSet::wordSize.

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

increment iterator to point at the next set bit

Definition at line 111 of file BitSet.h.

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

Friends And Related Function Documentation

friend class BitSet
friend

Definition at line 115 of file BitSet.h.

Member Data Documentation

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

Definition at line 122 of file BitSet.h.

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

Definition at line 122 of file BitSet.h.