Class sdm::iterator::CombinationIterator

Class List > sdm > iterator > CombinationIterator

The combination iterator provides a way to go simultaneously over multiple iterators in order to generate all combinations of items. More...

  • #include <combination_iterator.hpp>

Inherits the following classes: sdm::Iterator, std::enable_shared_from_this< CombinationIterator >

Public Types

Type Name
typedef std::shared_ptr< ItemIterator > single_iterator_type

Public Types inherited from sdm::Iterator

See sdm::Iterator

Type Name
typedef TItem item_type

Public Functions

Type Name
CombinationIterator ()
CombinationIterator (const std::vector< single_iterator_type > & begin_iterators, const std::vector< single_iterator_type > & end_iterators)
Construct a well defined combination iterator.
virtual std::shared_ptr< ItemIterator > copy () const
Copy function.
bool operator!= (const std::shared_ptr< ItemIterator > & other) const
virtual std::shared_ptr< Item > & operator* ()
Get a reference to the item.
virtual std::shared_ptr< ItemIterator > operator+ (number n) const
Get the n-step incremented iterator without modifying the current iterator.
virtual std::shared_ptr< ItemIterator > operator++ ()
Increment the iterator.
virtual std::shared_ptr< ItemIterator > operator+= (number n)
Increment the iterator of n steps.
virtual std::shared_ptr< Item > * operator-> ()
Get the address of the item.
bool operator== (const std::shared_ptr< ItemIterator > & other) const

Public Functions inherited from sdm::Iterator

See sdm::Iterator

Type Name
virtual std::shared_ptr< Iterator< TItem > > copy () const = 0
Copy function.
virtual bool operator!= (const std::shared_ptr< Iterator > & other) const = 0
Check if two iterators are differents.
virtual TItem & operator* () = 0
Get a reference to the item.
virtual std::shared_ptr< Iterator< TItem > > operator+ (number n) const = 0
Get the n-step incremented iterator without modifying the current iterator.
virtual std::shared_ptr< Iterator > operator++ () = 0
Increment the iterator.
virtual std::shared_ptr< Iterator< TItem > > operator+= (number n) = 0
Increment the iterator of n steps.
virtual TItem * operator-> () = 0
Get the address of the item.
virtual bool operator== (const std::shared_ptr< Iterator > & other) const = 0
Check if two iterators are equals. This function is used to check the end.
virtual ~Iterator ()

Protected Attributes

Type Name
std::vector< single_iterator_type > begin_iterators_
std::vector< single_iterator_type > current_iterators_
std::vector< single_iterator_type > end_iterators_
std::shared_ptr< Item > temporary_item

Protected Functions

Type Name
void debug ()

Detailed Description

The combination iterator is a classic SDMS iterator that will efficiently generate all combination of items included in subiterators. Acceptable subiterators are all SDMS iterators. Thus, it is possible to instanciate a combination iterator over combination iterators.

Public Types Documentation

typedef single_iterator_type

using sdm::iterator::CombinationIterator::single_iterator_type =  std::shared_ptr<ItemIterator>;

Public Functions Documentation

function CombinationIterator [1/2]

sdm::iterator::CombinationIterator::CombinationIterator () 

function CombinationIterator [2/2]

sdm::iterator::CombinationIterator::CombinationIterator (
    const std::vector< single_iterator_type > & begin_iterators,
    const std::vector< single_iterator_type > & end_iterators
) 

Parameters:

  • begin_iterators A list of begin iterators.
  • end_iterators A list of end iterators.

function copy

virtual std::shared_ptr< ItemIterator > sdm::iterator::CombinationIterator::copy () const

Returns:

the copied iterator

Implements sdm::Iterator::copy

function operator!=

bool sdm::iterator::CombinationIterator::operator!= (
    const std::shared_ptr< ItemIterator > & other
) const

function operator*

virtual std::shared_ptr< Item > & sdm::iterator::CombinationIterator::operator* () 

Returns:

TItem& the item

Implements sdm::Iterator::operator*

function operator+

virtual std::shared_ptr< ItemIterator > sdm::iterator::CombinationIterator::operator+ (
    number n
) const

Parameters:

  • n the number of step

Returns:

the n-step incremented copy iterator

Implements sdm::Iterator::operator+

function operator++

virtual std::shared_ptr< ItemIterator > sdm::iterator::CombinationIterator::operator++ () 

Returns:

the incremented iterator

Implements sdm::Iterator::operator++

function operator+=

virtual std::shared_ptr< ItemIterator > sdm::iterator::CombinationIterator::operator+= (
    number n
) 

Parameters:

  • n the number of step

Returns:

the n-step incremented iterator

Implements sdm::Iterator::operator+=

function operator->

virtual std::shared_ptr< Item > * sdm::iterator::CombinationIterator::operator-> () 

Returns:

TItem* the address of the item

Implements sdm::Iterator::operator->

function operator==

bool sdm::iterator::CombinationIterator::operator== (
    const std::shared_ptr< ItemIterator > & other
) const

Protected Attributes Documentation

variable begin_iterators_

std::vector<single_iterator_type> sdm::iterator::CombinationIterator::begin_iterators_;

variable current_iterators_

std::vector<single_iterator_type> sdm::iterator::CombinationIterator::current_iterators_;

variable end_iterators_

std::vector<single_iterator_type> sdm::iterator::CombinationIterator::end_iterators_;

variable temporary_item

std::shared_ptr<Item> sdm::iterator::CombinationIterator::temporary_item;

Protected Functions Documentation

function debug

void sdm::iterator::CombinationIterator::debug () 

The documentation for this class was generated from the following file src/sdm/utils/struct/iterator/combination_iterator.hpp