wpl::tool::window< InputIterator, WSize, Step, Bottom > Struct Template Reference

Sliding window. More...

#include <wipal/tool/window.hh>

Inheritance diagram for wpl::tool::window< InputIterator, WSize, Step, Bottom >:
wpl::tool::iterator< Bottom > wpl::tool::static_base< Bottom >

List of all members.

Public Types

enum  { max_size = WSize, step = Step }
Static hierarchies related types

typedef HIDDEN exact_type
typedef HIDDEN value_type
Iterator types.

typedef ssize_t difference_type
typedef value_type * pointer
typedef value_type & reference
typedef std::input_iterator_tag iterator_category

Public Member Functions

template<class Iterable >
 window (Iterable &, bool)
const InputIterator::value_type & operator[] (unsigned i) const
bool last () const
Abstract method implementations

bool equal (const window &) const
void increment ()
const value_type & get () const
const value_type * get_ptr () const
Equality checks

bool operator== (const exact_type &) const
bool operator!= (const exact_type &) const
Increment operators

const exact_typeoperator++ ()
exact_type operator++ (int)
Indirections

const value_type & operator* () const
const value_type * operator-> () const
Downcast methods

const exact_typeexact () const
exact_typeexact ()
const exact_typeexact_ptr () const
exact_typeexact_ptr ()

Protected Attributes

bool at_end_
InputIterator next_
InputIterator last_
value_type v_

Detailed Description

template<class InputIterator, unsigned WSize, unsigned Step = 1, class Bottom = bottom>
struct wpl::tool::window< InputIterator, WSize, Step, Bottom >

Sliding window.

window provides a sliding window over a sequence. It behaves as an iterator which value type is a container for the window's elements. Slide the window using its operator++() . An operator[]() is provided for convenience.

Parameters:
InputIterator The sequence's input iterator type.
WSize The window's size (length).
Step Number of elements to "eat" when calling increment().
Bottom Exact type or bottom (see static_base).
 typedef std::vector<int>          vector_type;
 typedef vector_type::iterator     iterator_type;
 typedef window<iterator_type, 2>  window_type;

 vector_type v;
 // Fill the vector.

 window_type w (v, false);
 window_type end (v, true);

 while(w != end)
   {
      std::cout << w[0] << std::endl << w[1] << std::endl << std::endl;
      ++w;
   }
See also:
window_maker

Member Enumeration Documentation

template<class InputIterator , unsigned WSize, unsigned Step = 1, class Bottom = bottom>
anonymous enum
Enumerator:
max_size 

< Window's maximum size.

step 

< Window's increment step.


The documentation for this struct was generated from the following files:

Generated by  doxygen 1.6.2