Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

BTK::PredicateIterator< Predicate, Iterator, Strategy > Class Template Reference

#include <predicate_iterator.h>

Collaboration diagram for BTK::PredicateIterator< Predicate, Iterator, Strategy >:

Collaboration graph
[legend]
List of all members.

[NOHEADER]

bool operator== (self_type const &rhs) const
bool operator!= (self_type const &rhs) const
bool operator== (Iterator const &rhs) const
bool operator!= (Iterator const &rhs) const
bool operator== (Iterator const &lhs, self_type const &rhs)
bool operator!= (Iterator const &lhs, self_type const &rhs)

Public Types

typedef std::forward_iterator_tag iterator_category
typedef std::iterator_traits<
Iterator >::value_type 
value_type
typedef std::iterator_traits<
Iterator >::difference_type 
difference_type
typedef std::iterator_traits<
Iterator >::pointer 
pointer
typedef std::iterator_traits<
Iterator >::reference 
reference
typedef PredicateIterator<
Predicate, Iterator, Strategy > 
self_type
typedef Iterator iterator_type
typedef Predicate predicate_type
typedef Strategy strategy_type

Public Member Functions

 PredicateIterator (Iterator const &begin, Iterator const &end, Predicate const &p=Predicate())
 PredicateIterator (Iterator const &end, Predicate const &p=Predicate())
self_typeoperator++ ()
 Prefix increment.

self_type operator++ (int)
 Postfix increment.

reference operator * () const
 Iterator dereference operator.

pointer operator-> () const
 Iterator arrow dereference operator.

self_typeoperator= (self_type const &rhs)

Detailed Description

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
class BTK::PredicateIterator< Predicate, Iterator, Strategy >

PredicateIterator class. The PredicateIterator is a model of the STL concept Forward Iterator, with the notable exception that it takes a Predicate, which is an object that is used to select which elements are iterated over. In other words, elements that do not match the condition(s) specified by the Predicate are skipped over during iteration.

PredicateIterators may be constructed using any iterator type that supports the Forward Iterator interface, and any predicate type that is A) default constructable, B) copy constructable, and C) provides an operator() that accepts a T const & (where T is the value_type of the iterator), and returns a boolean value (true = will be iterated, false == will be skipped).

In order to implement selection most efficiently, a "match list" is precomputed when the PredicateIterator is constructed, and this list is used during iteration. Thus, the PredicateIterator iterates in amortized constant time, regardless of the complexity of the Predicate itself. Copying of PredicateIterators is also guaranteed to be performed in amortized constant time. Construction, for obvious reasons, is O(n), where n is the length of the sequence range being iterated.


Member Typedef Documentation

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
typedef std::iterator_traits<Iterator>::difference_type BTK::PredicateIterator< Predicate, Iterator, Strategy >::difference_type
 

STL-required iterator typedefs. Note that these are created using the std::iterator_traits template, which is part of the C++ standard, but makes use of partial template specialization, and thus may not be supported by older compilers.

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
typedef std::forward_iterator_tag BTK::PredicateIterator< Predicate, Iterator, Strategy >::iterator_category
 

STL-required iterator typedefs. Note that these are created using the std::iterator_traits template, which is part of the C++ standard, but makes use of partial template specialization, and thus may not be supported by older compilers.

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
typedef Iterator BTK::PredicateIterator< Predicate, Iterator, Strategy >::iterator_type
 

Useful, but not-STL-required iterator typedefs.

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
typedef std::iterator_traits<Iterator>::pointer BTK::PredicateIterator< Predicate, Iterator, Strategy >::pointer
 

STL-required iterator typedefs. Note that these are created using the std::iterator_traits template, which is part of the C++ standard, but makes use of partial template specialization, and thus may not be supported by older compilers.

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
typedef Predicate BTK::PredicateIterator< Predicate, Iterator, Strategy >::predicate_type
 

Useful, but not-STL-required iterator typedefs.

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
typedef std::iterator_traits<Iterator>::reference BTK::PredicateIterator< Predicate, Iterator, Strategy >::reference
 

STL-required iterator typedefs. Note that these are created using the std::iterator_traits template, which is part of the C++ standard, but makes use of partial template specialization, and thus may not be supported by older compilers.

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
typedef PredicateIterator<Predicate,Iterator,Strategy> BTK::PredicateIterator< Predicate, Iterator, Strategy >::self_type
 

Useful, but not-STL-required iterator typedefs.

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
typedef Strategy BTK::PredicateIterator< Predicate, Iterator, Strategy >::strategy_type
 

Useful, but not-STL-required iterator typedefs.

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
typedef std::iterator_traits<Iterator>::value_type BTK::PredicateIterator< Predicate, Iterator, Strategy >::value_type
 

STL-required iterator typedefs. Note that these are created using the std::iterator_traits template, which is part of the C++ standard, but makes use of partial template specialization, and thus may not be supported by older compilers.


Constructor & Destructor Documentation

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
BTK::PredicateIterator< Predicate, Iterator, Strategy >::PredicateIterator Iterator const &  begin,
Iterator const &  end,
Predicate const &  p = Predicate()
[inline]
 

Construct a PredicateIterator. Construct a PredicateIterator, given a predicate, and iterators corresponding to the beginning and end of a range [begin,end).

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
BTK::PredicateIterator< Predicate, Iterator, Strategy >::PredicateIterator Iterator const &  end,
Predicate const &  p = Predicate()
[inline]
 

Construct a PredicateIterator. Construct a PredicateIterator, given an iterator corresponding to the end of a range.


Member Function Documentation

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
reference BTK::PredicateIterator< Predicate, Iterator, Strategy >::operator *  )  const [inline]
 

Iterator dereference operator.

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
bool BTK::PredicateIterator< Predicate, Iterator, Strategy >::operator!= Iterator const &  rhs  )  const [inline]
 

Equality/Inequality comparisons.

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
bool BTK::PredicateIterator< Predicate, Iterator, Strategy >::operator!= self_type const &  rhs  )  const [inline]
 

Equality/Inequality comparisons.

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
self_type BTK::PredicateIterator< Predicate, Iterator, Strategy >::operator++ int   )  [inline]
 

Postfix increment.

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
self_type& BTK::PredicateIterator< Predicate, Iterator, Strategy >::operator++  )  [inline]
 

Prefix increment.

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
pointer BTK::PredicateIterator< Predicate, Iterator, Strategy >::operator->  )  const [inline]
 

Iterator arrow dereference operator.

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
self_type& BTK::PredicateIterator< Predicate, Iterator, Strategy >::operator= self_type const &  rhs  )  [inline]
 

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
bool BTK::PredicateIterator< Predicate, Iterator, Strategy >::operator== Iterator const &  rhs  )  const [inline]
 

Equality/Inequality comparisons.

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
bool BTK::PredicateIterator< Predicate, Iterator, Strategy >::operator== self_type const &  rhs  )  const [inline]
 

Equality/Inequality comparisons.


Friends And Related Function Documentation

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
bool operator!= Iterator const &  lhs,
self_type const &  rhs
[friend]
 

Equality/Inequality comparisons.

template<class Predicate, class Iterator, class Strategy = PointerListStrategy<Predicate,Iterator>>
bool operator== Iterator const &  lhs,
self_type const &  rhs
[friend]
 

Equality/Inequality comparisons.


The documentation for this class was generated from the following file:
Generated on Wed Apr 14 00:43:27 2004 for BTK by doxygen 1.3.6