21 #ifndef UNIQUEITERATOR_H
22 #define UNIQUEITERATOR_H
24 #include <tulip/memorypool.h>
34 template <
typename TYPE>
35 class CheckAllFunctor {
36 bool operator()(
const TYPE &) {
60 template <
typename TYPE,
typename TOCHECKFUNCTOR = CheckAllFunctor<TYPE> >
61 class UniqueIterator :
public Iterator<TYPE> {
63 UniqueIterator(Iterator<TYPE> *it, TOCHECKFUNCTOR checkFunctor = TOCHECKFUNCTOR()):_it(it), _checkFunctor(checkFunctor) {
77 inline bool hasNext() {
84 while(_it->hasNext()) {
87 if (_checkFunctor(curVal) ) {
88 if (_flag.find(curVal) == _flag.end()) {
102 std::set<TYPE> _flag;
106 TOCHECKFUNCTOR _checkFunctor;
115 template <
typename TYPE,
typename TOCHECKFUNCTOR = CheckAllFunctor<TYPE> >
116 class MPUniqueIterator :
public UniqueIterator<TYPE, TOCHECKFUNCTOR> ,
117 public MemoryPool<MPUniqueIterator<TYPE, TOCHECKFUNCTOR> > {
119 MPUniqueIterator(Iterator<TYPE> *it, TOCHECKFUNCTOR checkFunctor = TOCHECKFUNCTOR()):
120 UniqueIterator<TYPE, TOCHECKFUNCTOR>(it, checkFunctor) {
125 #endif // UNIQUEITERATOR_H