Static Value-Flow Analysis
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
SVF::CoreBitVector::CoreBitVectorIterator Class Reference

#include <CoreBitVector.h>

Public Types

using iterator_category = std::forward_iterator_tag
 
using value_type = u32_t
 
using difference_type = std::ptrdiff_t
 
using pointer = u32_t *
 
using reference = u32_t &
 

Public Member Functions

 CoreBitVectorIterator (void)=delete
 
 CoreBitVectorIterator (const CoreBitVector *cbv, bool end=false)
 
 CoreBitVectorIterator (const CoreBitVectorIterator &cbv)=default
 
 CoreBitVectorIterator (CoreBitVectorIterator &&cbv)=default
 
CoreBitVectorIteratoroperator= (const CoreBitVectorIterator &cbv)=default
 
CoreBitVectorIteratoroperator= (CoreBitVectorIterator &&cbv)=default
 
const CoreBitVectorIteratoroperator++ (void)
 Pre-increment: ++it. More...
 
const CoreBitVectorIterator operator++ (int)
 Post-increment: it++. More...
 
u32_t operator* (void) const
 Dereference: *it. More...
 
bool operator== (const CoreBitVectorIterator &rhs) const
 Equality: *this == rhs. More...
 
bool operator!= (const CoreBitVectorIterator &rhs) const
 Inequality: *this != rhs. More...
 

Private Member Functions

bool atEnd (void) const
 

Private Attributes

const CoreBitVectorcbv
 CoreBitVector we are iterating over. More...
 
std::vector< Word >::const_iterator wordIt
 Word in words we are looking at. More...
 
u32_t bit
 

Detailed Description

Definition at line 147 of file CoreBitVector.h.

Member Typedef Documentation

◆ difference_type

Definition at line 152 of file CoreBitVector.h.

◆ iterator_category

Definition at line 150 of file CoreBitVector.h.

◆ pointer

Definition at line 153 of file CoreBitVector.h.

◆ reference

Definition at line 154 of file CoreBitVector.h.

◆ value_type

Definition at line 151 of file CoreBitVector.h.

Constructor & Destructor Documentation

◆ CoreBitVectorIterator() [1/4]

SVF::CoreBitVector::CoreBitVectorIterator::CoreBitVectorIterator ( void  )
delete

◆ CoreBitVectorIterator() [2/4]

SVF::CoreBitVector::CoreBitVectorIterator::CoreBitVectorIterator ( const CoreBitVector cbv,
bool  end = false 
)

Returns an iterator to the beginning of cbv if end is false, and to the end of cbv if end is true.

Definition at line 387 of file CoreBitVector.cpp.

388  : cbv(cbv), bit(0)
389 {
390  wordIt = end ? cbv->words.end() : cbv->words.begin();
391  // If user didn't request an end iterator, or words is non-empty,
392  // from 0, go to the next bit. But if the 0 bit is set, we don't
393  // need to because that is the first element.
394  if (wordIt != cbv->words.end() && !(cbv->words[0] & (Word)0b1)) ++(*this);
395 }
const CoreBitVector * cbv
CoreBitVector we are iterating over.
std::vector< Word >::const_iterator wordIt
Word in words we are looking at.
std::vector< Word > words
Our actual bit vector.
const_iterator end(void) const
unsigned long long Word
Definition: CoreBitVector.h:33

◆ CoreBitVectorIterator() [3/4]

SVF::CoreBitVector::CoreBitVectorIterator::CoreBitVectorIterator ( const CoreBitVectorIterator cbv)
default

◆ CoreBitVectorIterator() [4/4]

SVF::CoreBitVector::CoreBitVectorIterator::CoreBitVectorIterator ( CoreBitVectorIterator &&  cbv)
default

Member Function Documentation

◆ atEnd()

bool SVF::CoreBitVector::CoreBitVectorIterator::atEnd ( void  ) const
private

Definition at line 452 of file CoreBitVector.cpp.

453 {
454  return wordIt == cbv->words.end();
455 }

◆ operator!=()

bool SVF::CoreBitVector::CoreBitVectorIterator::operator!= ( const CoreBitVectorIterator rhs) const

Inequality: *this != rhs.

Definition at line 446 of file CoreBitVector.cpp.

447 {
448  assert(cbv == rhs.cbv && "CoreBitVectorIterator::!=: comparing iterators from different CBVs");
449  return !(*this == rhs);
450 }

◆ operator*()

u32_t SVF::CoreBitVector::CoreBitVectorIterator::operator* ( void  ) const

Dereference: *it.

Definition at line 427 of file CoreBitVector.cpp.

428 {
429  assert(!atEnd() && "CoreBitVectorIterator::*: dereferencing end!");
430  size_t wordsIndex = wordIt - cbv->words.begin();
431  // Add where the bit vector starts (offset), with the number of bits
432  // in the passed words (the index encodes how many we have completely
433  // passed since it is position - 1) and the bit we are up to for the
434  // current word (i.e., in the n+1th)
435  return cbv->offset + wordsIndex * WordSize + bit;
436 }
static const size_t WordSize
Definition: CoreBitVector.h:34
u32_t offset
The first bit of the first word.

◆ operator++() [1/2]

const CoreBitVector::CoreBitVectorIterator SVF::CoreBitVector::CoreBitVectorIterator::operator++ ( int  )

Post-increment: it++.

Definition at line 419 of file CoreBitVector.cpp.

420 {
421  assert(!atEnd() && "CoreBitVectorIterator::++(pre): incrementing past end!");
422  CoreBitVectorIterator old = *this;
423  ++*this;
424  return old;
425 }

◆ operator++() [2/2]

const CoreBitVector::CoreBitVectorIterator & SVF::CoreBitVector::CoreBitVectorIterator::operator++ ( void  )

Pre-increment: ++it.

Definition at line 397 of file CoreBitVector.cpp.

398 {
399  assert(!atEnd() && "CoreBitVectorIterator::++(pre): incrementing past end!");
400 
401  ++bit;
402  // Check if no more bits in wordIt. Find word with a bit set.
403  if (bit == WordSize || (*wordIt >> bit) == 0)
404  {
405  bit = 0;
406  ++wordIt;
407  while (wordIt != cbv->words.end() && *wordIt == 0) ++wordIt;
408  }
409 
410  // Find set bit if we're not at the end.
411  if (wordIt != cbv->words.end())
412  {
413  while (bit != WordSize && (*wordIt & ((Word)0b1 << bit)) == 0) ++bit;
414  }
415 
416  return *this;
417 }

◆ operator=() [1/2]

CoreBitVectorIterator& SVF::CoreBitVector::CoreBitVectorIterator::operator= ( const CoreBitVectorIterator cbv)
default

◆ operator=() [2/2]

CoreBitVectorIterator& SVF::CoreBitVector::CoreBitVectorIterator::operator= ( CoreBitVectorIterator &&  cbv)
default

◆ operator==()

bool SVF::CoreBitVector::CoreBitVectorIterator::operator== ( const CoreBitVectorIterator rhs) const

Equality: *this == rhs.

Definition at line 438 of file CoreBitVector.cpp.

439 {
440  assert(cbv == rhs.cbv && "CoreBitVectorIterator::==: comparing iterators from different CBVs");
441  // When we're at the end we don't care about bit.
442  if (wordIt == cbv->words.end()) return rhs.wordIt == cbv->words.end();
443  return wordIt == rhs.wordIt && bit == rhs.bit;
444 }

Member Data Documentation

◆ bit

u32_t SVF::CoreBitVector::CoreBitVectorIterator::bit
private

Current bit in wordIt we are looking at (index into *wordIt).

Definition at line 193 of file CoreBitVector.h.

◆ cbv

const CoreBitVector* SVF::CoreBitVector::CoreBitVectorIterator::cbv
private

CoreBitVector we are iterating over.

Definition at line 188 of file CoreBitVector.h.

◆ wordIt

std::vector<Word>::const_iterator SVF::CoreBitVector::CoreBitVectorIterator::wordIt
private

Word in words we are looking at.

Definition at line 190 of file CoreBitVector.h.


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