souffle  2.0.2-371-g6315b36
Public Types | Public Member Functions | Private Types | Private Attributes
souffle::EquivalenceRelation< TupleType >::iterator Class Reference

#include <EquivalenceRelation.h>

Collaboration diagram for souffle::EquivalenceRelation< TupleType >::iterator:
Collaboration graph

Public Types

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

Public Member Functions

 iterator (const EquivalenceRelation *br)
 
 iterator (const EquivalenceRelation *br, bool)
 
 iterator (const EquivalenceRelation *br, const StatesBucket within)
 
 iterator (const EquivalenceRelation *br, const typename TupleType::value_type former, const StatesBucket within)
 
 iterator (const EquivalenceRelation *br, const typename TupleType::value_type former, typename TupleType::value_type latter, const StatesBucket within)
 
 iterator (const iterator &other)=default
 
 iterator (iterator &&other)=default
 
bool operator!= (const iterator &other) const
 
const TupleType & operator* () const
 
iteratoroperator++ ()
 
const TupleType * operator-> () const
 
iteratoroperator= (const iterator &other)=default
 
bool operator== (const iterator &other) const
 
void setAnterior (const typename TupleType::value_type a)
 explicit set first half of cPair More...
 
void setPosterior (const typename TupleType::value_type b)
 explicit set second half of cPair More...
 
void updateAnterior ()
 quick update to whatever the current index is pointing to More...
 
void updatePosterior ()
 quick update to whatever the current index is pointing to More...
 

Private Types

enum  IterType { ALL, ANTERIOR, ANTPOST, WITHIN }
 

Private Attributes

const EquivalenceRelationbr = nullptr
 
size_t cAnteriorIndex = 0
 
TupleType cPair
 
size_t cPosteriorIndex = 0
 
StatesBucket djSetList
 
StatesMap::iterator djSetMapListEnd
 
StatesMap::iterator djSetMapListIt
 
bool isEndVal = false
 
IterType ityp
 

Detailed Description

template<typename TupleType>
class souffle::EquivalenceRelation< TupleType >::iterator

Definition at line 261 of file EquivalenceRelation.h.

Member Typedef Documentation

◆ difference_type

template<typename TupleType >
using souffle::EquivalenceRelation< TupleType >::iterator::difference_type = ptrdiff_t

Definition at line 265 of file EquivalenceRelation.h.

◆ iterator_category

template<typename TupleType >
typedef std::forward_iterator_tag souffle::EquivalenceRelation< TupleType >::iterator::iterator_category

Definition at line 263 of file EquivalenceRelation.h.

◆ pointer

template<typename TupleType >
using souffle::EquivalenceRelation< TupleType >::iterator::pointer = value_type*

Definition at line 266 of file EquivalenceRelation.h.

◆ reference

template<typename TupleType >
using souffle::EquivalenceRelation< TupleType >::iterator::reference = value_type&

Definition at line 267 of file EquivalenceRelation.h.

◆ value_type

template<typename TupleType >
using souffle::EquivalenceRelation< TupleType >::iterator::value_type = TupleType

Definition at line 264 of file EquivalenceRelation.h.

Member Enumeration Documentation

◆ IterType

template<typename TupleType >
enum souffle::EquivalenceRelation::iterator::IterType
private
Enumerator
ALL 
ANTERIOR 
ANTPOST 
WITHIN 

Definition at line 459 of file EquivalenceRelation.h.

459 :
460  /**

Constructor & Destructor Documentation

◆ iterator() [1/7]

template<typename TupleType >
souffle::EquivalenceRelation< TupleType >::iterator::iterator ( const EquivalenceRelation br,
bool   
)
inlineexplicit

Definition at line 270 of file EquivalenceRelation.h.

275  : br(br), ityp(IterType::WITHIN), djSetList(within) {

Referenced by souffle::EquivalenceRelation< Arity >::size().

◆ iterator() [2/7]

template<typename TupleType >
souffle::EquivalenceRelation< TupleType >::iterator::iterator ( const EquivalenceRelation br)
inlineexplicit

Definition at line 273 of file EquivalenceRelation.h.

275  : br(br), ityp(IterType::WITHIN), djSetList(within) {
276  // empty dj set
277  if (djSetList->size() == 0) {
278  isEndVal = true;
279  }
280 
281  updateAnterior();
282  updatePosterior();
283  }
284 
285  // ANTERIOR: iterator that yields all (former, _) \in djset(former) (djset(former) === within)
286  explicit iterator(const EquivalenceRelation* br, const typename TupleType::value_type former,
287  const StatesBucket within)

References souffle::EquivalenceRelation< TupleType >::iterator::djSetList, souffle::EquivalenceRelation< TupleType >::iterator::isEndVal, souffle::PiggyList< T >::size(), souffle::EquivalenceRelation< TupleType >::iterator::updateAnterior(), and souffle::EquivalenceRelation< TupleType >::iterator::updatePosterior().

Here is the call graph for this function:

◆ iterator() [3/7]

template<typename TupleType >
souffle::EquivalenceRelation< TupleType >::iterator::iterator ( const EquivalenceRelation br,
const StatesBucket  within 
)
inlineexplicit

Definition at line 290 of file EquivalenceRelation.h.

◆ iterator() [4/7]

template<typename TupleType >
souffle::EquivalenceRelation< TupleType >::iterator::iterator ( const EquivalenceRelation br,
const typename TupleType::value_type  former,
const StatesBucket  within 
)
inlineexplicit

Definition at line 302 of file EquivalenceRelation.h.

302  {
303  isEndVal = true;
304  }
305 
306  setAnterior(former);
307  setPosterior(latter);
308  }
309 
310  /** explicit set first half of cPair */
311  inline void setAnterior(const typename TupleType::value_type a) {

References souffle::EquivalenceRelation< TupleType >::iterator::isEndVal.

◆ iterator() [5/7]

template<typename TupleType >
souffle::EquivalenceRelation< TupleType >::iterator::iterator ( const EquivalenceRelation br,
const typename TupleType::value_type  former,
typename TupleType::value_type  latter,
const StatesBucket  within 
)
inlineexplicit

Definition at line 315 of file EquivalenceRelation.h.

316  {
317  this->cPair[0] = this->djSetList->get(this->cAnteriorIndex);
318  }
319 
320  /** explicit set second half of cPair */
321  inline void setPosterior(const typename TupleType::value_type b) {
322  this->cPair[1] = b;
323  }
324 

References souffle::EquivalenceRelation< TupleType >::iterator::cAnteriorIndex, souffle::EquivalenceRelation< TupleType >::iterator::cPair, souffle::EquivalenceRelation< TupleType >::iterator::djSetList, and souffle::PiggyList< T >::get().

Here is the call graph for this function:

◆ iterator() [6/7]

template<typename TupleType >
souffle::EquivalenceRelation< TupleType >::iterator::iterator ( const iterator other)
default

◆ iterator() [7/7]

template<typename TupleType >
souffle::EquivalenceRelation< TupleType >::iterator::iterator ( iterator &&  other)
default

Member Function Documentation

◆ operator!=()

template<typename TupleType >
bool souffle::EquivalenceRelation< TupleType >::iterator::operator!= ( const iterator other) const
inline

Definition at line 358 of file EquivalenceRelation.h.

360  {

◆ operator*()

template<typename TupleType >
const TupleType& souffle::EquivalenceRelation< TupleType >::iterator::operator* ( ) const
inline

Definition at line 362 of file EquivalenceRelation.h.

364  {

◆ operator++()

template<typename TupleType >
iterator& souffle::EquivalenceRelation< TupleType >::iterator::operator++ ( )
inline

Definition at line 371 of file EquivalenceRelation.h.

377  {
378  throw std::out_of_range("error: encountered a zero size djset");
379  }
380 
381  // update our cAnterior and cPosterior
382  cAnteriorIndex = 0;
383  cPosteriorIndex = 0;
384  updateAnterior();
385  updatePosterior();
386  }
387 
388  // we moved our anterior along one
389  updateAnterior();
390 
391  cPosteriorIndex = 0;
392  updatePosterior();
393  }
394  // we just moved our posterior along one
395  updatePosterior();
396 
397  break;
398  case IterType::ANTERIOR:
399  // step posterior along one, and if we can't, then we're done.
400  if (++cPosteriorIndex == djSetList->size()) {
401  isEndVal = true;
402  return *this;
403  }
404  updatePosterior();
405 
406  break;
407  case IterType::ANTPOST:
408  // fixed anterior and posterior literally only points to one, so if we increment, its the
409  // end
410  isEndVal = true;
411  break;
412  case IterType::WITHIN:
413  // move posterior along one
414  // see if we can't move the posterior along
415  if (++cPosteriorIndex == djSetList->size()) {
416  // move anterior along one
417  // see if we can't move the anterior along one
418  if (++cAnteriorIndex == djSetList->size()) {
419  isEndVal = true;
420  return *this;
421  }
422 
423  // we moved our anterior along one
424  updateAnterior();
425 
426  cPosteriorIndex = 0;
427  updatePosterior();
428  }
429  // we just moved our posterior along one
430  updatePosterior();
431  break;
432  }
433 
434  return *this;
435  }
436 
437  private:
438  const EquivalenceRelation* br = nullptr;
439  // special tombstone value to notify that this iter represents the end
440  bool isEndVal = false;
441 
442  // all the different types of iterator this can be
443  enum IterType { ALL, ANTERIOR, ANTPOST, WITHIN };
444  IterType ityp;
445 
446  TupleType cPair;
447 
448  // the disjoint set that we're currently iterating through
450  typename StatesMap::iterator djSetMapListIt;
451  typename StatesMap::iterator djSetMapListEnd;

◆ operator->()

template<typename TupleType >
const TupleType* souffle::EquivalenceRelation< TupleType >::iterator::operator-> ( ) const
inline

◆ operator=()

template<typename TupleType >
iterator& souffle::EquivalenceRelation< TupleType >::iterator::operator= ( const iterator other)
default

◆ operator==()

template<typename TupleType >
bool souffle::EquivalenceRelation< TupleType >::iterator::operator== ( const iterator other) const
inline

Definition at line 353 of file EquivalenceRelation.h.

355  {
356  if (isEndVal) {

References souffle::EquivalenceRelation< TupleType >::iterator::isEndVal.

◆ setAnterior()

template<typename TupleType >
void souffle::EquivalenceRelation< TupleType >::iterator::setAnterior ( const typename TupleType::value_type  a)
inline

explicit set first half of cPair

Definition at line 327 of file EquivalenceRelation.h.

337  {

◆ setPosterior()

template<typename TupleType >
void souffle::EquivalenceRelation< TupleType >::iterator::setPosterior ( const typename TupleType::value_type  b)
inline

explicit set second half of cPair

Definition at line 337 of file EquivalenceRelation.h.

337  {
338  if (isEndVal && other.isEndVal) return br == other.br;
339  return isEndVal == other.isEndVal && cPair == other.cPair;

References souffle::EquivalenceRelation< TupleType >::iterator::br, souffle::EquivalenceRelation< TupleType >::iterator::cPair, and souffle::EquivalenceRelation< TupleType >::iterator::isEndVal.

◆ updateAnterior()

template<typename TupleType >
void souffle::EquivalenceRelation< TupleType >::iterator::updateAnterior ( )
inline

quick update to whatever the current index is pointing to

Definition at line 332 of file EquivalenceRelation.h.

337  {

Referenced by souffle::EquivalenceRelation< TupleType >::iterator::iterator().

◆ updatePosterior()

template<typename TupleType >
void souffle::EquivalenceRelation< TupleType >::iterator::updatePosterior ( )
inline

quick update to whatever the current index is pointing to

Definition at line 342 of file EquivalenceRelation.h.

342  {
343  return !((*this) == other);
344  }

Referenced by souffle::EquivalenceRelation< TupleType >::iterator::iterator().

Field Documentation

◆ br

template<typename TupleType >
const EquivalenceRelation* souffle::EquivalenceRelation< TupleType >::iterator::br = nullptr
private

◆ cAnteriorIndex

template<typename TupleType >
size_t souffle::EquivalenceRelation< TupleType >::iterator::cAnteriorIndex = 0
private

◆ cPair

template<typename TupleType >
TupleType souffle::EquivalenceRelation< TupleType >::iterator::cPair
private

◆ cPosteriorIndex

template<typename TupleType >
size_t souffle::EquivalenceRelation< TupleType >::iterator::cPosteriorIndex = 0
private

Definition at line 472 of file EquivalenceRelation.h.

◆ djSetList

template<typename TupleType >
StatesBucket souffle::EquivalenceRelation< TupleType >::iterator::djSetList
private

◆ djSetMapListEnd

template<typename TupleType >
StatesMap::iterator souffle::EquivalenceRelation< TupleType >::iterator::djSetMapListEnd
private

◆ djSetMapListIt

template<typename TupleType >
StatesMap::iterator souffle::EquivalenceRelation< TupleType >::iterator::djSetMapListIt
private

◆ isEndVal

template<typename TupleType >
bool souffle::EquivalenceRelation< TupleType >::iterator::isEndVal = false
private

◆ ityp

template<typename TupleType >
IterType souffle::EquivalenceRelation< TupleType >::iterator::ityp
private

Definition at line 460 of file EquivalenceRelation.h.

Referenced by souffle::EquivalenceRelation< Arity >::size().


The documentation for this class was generated from the following file:
souffle::PiggyList::get
T & get(size_t index) const
Retrieve a reference to the stored value at index.
Definition: PiggyList.h:235
souffle::PiggyList::size
size_t size() const
Well, returns the number of nodes exist within the list + number of nodes queued to be inserted The r...
Definition: PiggyList.h:181
souffle::EquivalenceRelation::iterator::cPosteriorIndex
size_t cPosteriorIndex
Definition: EquivalenceRelation.h:472
souffle::EquivalenceRelation::iterator::setAnterior
void setAnterior(const typename TupleType::value_type a)
explicit set first half of cPair
Definition: EquivalenceRelation.h:327
souffle::EquivalenceRelation::iterator::djSetMapListEnd
StatesMap::iterator djSetMapListEnd
Definition: EquivalenceRelation.h:467
souffle::EquivalenceRelation::iterator::iterator
iterator(const EquivalenceRelation *br, bool)
Definition: EquivalenceRelation.h:270
souffle::EquivalenceRelation::iterator::br
const EquivalenceRelation * br
Definition: EquivalenceRelation.h:454
souffle::EquivalenceRelation::iterator::cPair
TupleType cPair
Definition: EquivalenceRelation.h:462
souffle::EquivalenceRelation::iterator::ityp
IterType ityp
Definition: EquivalenceRelation.h:460
souffle::EquivalenceRelation::iterator::updateAnterior
void updateAnterior()
quick update to whatever the current index is pointing to
Definition: EquivalenceRelation.h:332
souffle::EquivalenceRelation::iterator::isEndVal
bool isEndVal
Definition: EquivalenceRelation.h:456
souffle::EquivalenceRelation::iterator::ANTERIOR
@ ANTERIOR
Definition: EquivalenceRelation.h:459
souffle::EquivalenceRelation::iterator::cAnteriorIndex
size_t cAnteriorIndex
Definition: EquivalenceRelation.h:470
souffle::EquivalenceRelation::iterator::ANTPOST
@ ANTPOST
Definition: EquivalenceRelation.h:459
souffle::EquivalenceRelation::StatesBucket
StatesList * StatesBucket
Definition: EquivalenceRelation.h:64
souffle::EquivalenceRelation::iterator::djSetList
StatesBucket djSetList
Definition: EquivalenceRelation.h:465
b
l j a showGridBackground &&c b raw series this eventEmitter b
Definition: htmlJsChartistMin.h:15
souffle::EquivalenceRelation::EquivalenceRelation
EquivalenceRelation()
Definition: EquivalenceRelation.h:72
souffle::EquivalenceRelation::iterator::IterType
IterType
Definition: EquivalenceRelation.h:459
souffle::EquivalenceRelation::iterator::updatePosterior
void updatePosterior()
quick update to whatever the current index is pointing to
Definition: EquivalenceRelation.h:342
souffle::EquivalenceRelation::iterator::WITHIN
@ WITHIN
Definition: EquivalenceRelation.h:459
souffle::EquivalenceRelation::iterator::setPosterior
void setPosterior(const typename TupleType::value_type b)
explicit set second half of cPair
Definition: EquivalenceRelation.h:337
souffle::EquivalenceRelation::iterator::djSetMapListIt
StatesMap::iterator djSetMapListIt
Definition: EquivalenceRelation.h:466
souffle::EquivalenceRelation::iterator::ALL
@ ALL
Definition: EquivalenceRelation.h:459