tool::iterable< Bottom > Struct Template Reference

Base class to represent iterable objects. More...

#include <wipal/tool/iterable.hh>

List of all members.

Iterator types

typedef iterator const_iterator
typedef wp_type (iterator, exact_type) iterator

Public Member Functions

typedef wp_get_exact (Bottom, iterable< Bottom >) exact_type
iterator begin () const
iterator end () const
template<class OutputIterator>
void operator() (const OutputIterator &output) const
Apply a function/functor to each element
template<class Functor>
void for_each (Functor &f) const
template<class Functor>
void for_each (const Functor &f) const


Detailed Description

template<class Bottom = bottom>
struct tool::iterable< Bottom >

Base class to represent iterable objects.

An iterable oject aggregates elements on which iteration is possible. iterable provides basic mechanisms to permorm this iteration. That is, it provides the iterable::iterator and iterable::const_iterator types, begin() / end() methods, and operator()().

In order to subclass iterable, you must define an iterator type for your iterable class. This type must have a similar constructor:

 my_iterator::my_iterator(const my_iterable& e, bool at_end);

The first argument refers to the object you want to iterate on. The second one indicates whether to point the iterator at the begining or past the end of this object's elements.

Once you defined this iterator type, just declare it as part of your iterable class' virtual types :

 template <MyIterableParams>
 struct types< MyIterable<MyIterableParams> >
 {
   typedef my_iterator iterator;
 };

See also:
iterator

Member Function Documentation

template<class Bottom = bottom>
typedef tool::iterable< Bottom >::wp_get_exact ( Bottom  ,
iterable< Bottom >   
)

Exact type for this template instantiation.

template<class B>
iterable< B >::iterator tool::iterable< B >::begin (  )  const [inline]

Get an iterator to the first element.

template<class B>
iterable< B >::iterator tool::iterable< B >::end (  )  const [inline]

Get an iterator to the end (past the last element).

template<class B>
template<class O>
void tool::iterable< B >::operator() ( const O &  output  )  const [inline]

Copy elements to output .


The documentation for this struct was generated from the following files:
Generated on Wed Jan 16 16:15:14 2008 for wipal by  doxygen 1.5.4