STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | Friends | List of all members
__gnu_parallel::_GuardedIterator< _RAIter, _Compare > Class Template Reference

_Iterator wrapper supporting an implicit supremum at the end of the sequence, dominating all comparisons. More...

#include <parallel/multiway_merge.h>

Public Member Functions

 _GuardedIterator (_RAIter __begin, _RAIter __end, _Compare &__comp)
 Constructor. Sets iterator to beginning of sequence. More...
 
_GuardedIterator< _RAIter,
_Compare > & 
operator++ ()
 Pre-increment operator. More...
 
std::iterator_traits< _RAIter >
::value_type & 
operator* ()
 Dereference operator. More...
 
 operator _RAIter ()
 Convert to wrapped iterator. More...
 

Private Attributes

_RAIter _M_current
 Current iterator __position. More...
 
_RAIter _M_end
 End iterator of the sequence. More...
 
_Compare & __comp
 _Compare. More...
 

Friends

bool operator< (_GuardedIterator< _RAIter, _Compare > &__bi1, _GuardedIterator< _RAIter, _Compare > &__bi2)
 Compare two elements referenced by guarded iterators. More...
 
bool operator<= (_GuardedIterator< _RAIter, _Compare > &__bi1, _GuardedIterator< _RAIter, _Compare > &__bi2)
 Compare two elements referenced by guarded iterators. More...
 

Detailed Description

template<typename _RAIter, typename _Compare>
class __gnu_parallel::_GuardedIterator< _RAIter, _Compare >

_Iterator wrapper supporting an implicit supremum at the end of the sequence, dominating all comparisons.

The implicit supremum comes with a performance cost.

Deriving from _RAIter is not possible since _RAIter need not be a class.

Constructor & Destructor Documentation

template<typename _RAIter , typename _Compare >
__gnu_parallel::_GuardedIterator< _RAIter, _Compare >::_GuardedIterator ( _RAIter  __begin,
_RAIter  __end,
_Compare &  __comp 
)
inline

Constructor. Sets iterator to beginning of sequence.

Parameters
__beginBegin iterator of sequence.
__endEnd iterator of sequence.
__compComparator provided for associated overloaded compare operators.
92  : _M_current(__begin), _M_end(__end), __comp(__comp)
93  { }
_RAIter _M_end
End iterator of the sequence.
Definition: multiway_merge.h:80
_Compare & __comp
_Compare.
Definition: multiway_merge.h:83
_RAIter _M_current
Current iterator __position.
Definition: multiway_merge.h:77

Member Function Documentation

template<typename _RAIter , typename _Compare >
__gnu_parallel::_GuardedIterator< _RAIter, _Compare >::operator _RAIter ( )
inline

Convert to wrapped iterator.

Returns
Wrapped iterator.
113  { return _M_current; }
_RAIter _M_current
Current iterator __position.
Definition: multiway_merge.h:77
template<typename _RAIter , typename _Compare >
std::iterator_traits<_RAIter>::value_type& __gnu_parallel::_GuardedIterator< _RAIter, _Compare >::operator* ( )
inline

Dereference operator.

Returns
Referenced element.
108  { return *_M_current; }
_RAIter _M_current
Current iterator __position.
Definition: multiway_merge.h:77
template<typename _RAIter , typename _Compare >
_GuardedIterator<_RAIter, _Compare>& __gnu_parallel::_GuardedIterator< _RAIter, _Compare >::operator++ ( )
inline

Pre-increment operator.

Returns
This.
99  {
100  ++_M_current;
101  return *this;
102  }
_RAIter _M_current
Current iterator __position.
Definition: multiway_merge.h:77

Friends And Related Function Documentation

template<typename _RAIter , typename _Compare >
bool operator< ( _GuardedIterator< _RAIter, _Compare > &  __bi1,
_GuardedIterator< _RAIter, _Compare > &  __bi2 
)
friend

Compare two elements referenced by guarded iterators.

Parameters
__bi1First iterator.
__bi2Second iterator.
Returns
true if less.
122  {
123  if (__bi1._M_current == __bi1._M_end) // __bi1 is sup
124  return __bi2._M_current == __bi2._M_end; // __bi2 is not sup
125  if (__bi2._M_current == __bi2._M_end) // __bi2 is sup
126  return true;
127  return (__bi1.__comp)(*__bi1, *__bi2); // normal compare
128  }
template<typename _RAIter , typename _Compare >
bool operator<= ( _GuardedIterator< _RAIter, _Compare > &  __bi1,
_GuardedIterator< _RAIter, _Compare > &  __bi2 
)
friend

Compare two elements referenced by guarded iterators.

Parameters
__bi1First iterator.
__bi2Second iterator.
Returns
True if less equal.
137  {
138  if (__bi2._M_current == __bi2._M_end) // __bi1 is sup
139  return __bi1._M_current != __bi1._M_end; // __bi2 is not sup
140  if (__bi1._M_current == __bi1._M_end) // __bi2 is sup
141  return false;
142  return !(__bi1.__comp)(*__bi2, *__bi1); // normal compare
143  }

Member Data Documentation

template<typename _RAIter , typename _Compare >
_Compare& __gnu_parallel::_GuardedIterator< _RAIter, _Compare >::__comp
private

_Compare.

template<typename _RAIter , typename _Compare >
_RAIter __gnu_parallel::_GuardedIterator< _RAIter, _Compare >::_M_current
private

Current iterator __position.

template<typename _RAIter , typename _Compare >
_RAIter __gnu_parallel::_GuardedIterator< _RAIter, _Compare >::_M_end
private

End iterator of the sequence.


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