20 #ifndef UNIQUEITERATOR_H 21 #define UNIQUEITERATOR_H 25 #include <tulip/Iterator.h> 26 #include <tulip/StlIterator.h> 27 #include <tulip/memorypool.h> 38 bool operator()(
const T &) {
65 template <
typename T,
typename CheckFunc = CheckAllFunctor<T>>
69 : _it(it), _checkFunctor(checkFunctor) {
90 while (_it->hasNext()) {
93 if (_checkFunctor(curVal)) {
94 if (_flag.find(curVal) == _flag.end()) {
111 CheckFunc _checkFunctor;
114 template <
typename T,
typename CheckFunc = CheckAllFunctor<T>>
116 public MemoryPool<MPUniqueIterator<T, CheckFunc>> {
118 MPUniqueIterator(
Iterator<T> *it, CheckFunc checkFunctor = CheckFunc())
138 template <
typename T,
typename CheckFunc = CheckAllFunctor<T>>
140 return new MPUniqueIterator<T, CheckFunc>(it, checkFunctor);
158 template <
typename Container,
typename CheckFunc = CheckAllFunctor<
typename Container::value_type>>
159 typename std::enable_if<has_const_iterator<Container>::value,
162 CheckFunc checkFunctor = CheckFunc()) {
163 return new MPUniqueIterator<typename Container::value_type, CheckFunc>(
stlIterator(stlContainer),
167 #endif // UNIQUEITERATOR_H That class implement a default functor that always returns true.
Interface for Tulip iterators. Allows basic iteration operations only.
T next()
Moves the Iterator on the next element.
UniqueIterator< T > * uniqueIterator(Iterator< T > *it, CheckFunc checkFunctor=CheckFunc())
Convenient function for creating a UniqueIterator.
bool hasNext()
Tells if the sequence is at its end.
UniqueIterator enables to remove duplicated elements in an iterator.
std::enable_if< has_const_iterator< Container >::value, StlIterator< typename Container::value_type, typename Container::const_iterator > * >::type stlIterator(const Container &stlContainer)
Convenient function for creating a StlIterator from a stl container.