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

Sliding window. More...

#include <trace-tools/tool/window.hh>

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

tool::iterator< Bottom > tool::static_base< Bottom >

List of all members.

Public Types

typedef HIDDEN exact_type
typedef HIDDEN value_type
typedef size_t difference_type

Public Member Functions

template<class Iterable>
 window (Iterable &, bool)
bool equal (const window &) const
void increment ()
const value_typeget () const
const value_typeget_ptr () const
const
InputIterator::value_type & 
operator[] (unsigned i) 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_typeoperator * () const
const value_typeoperator-> () 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 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 Typedef Documentation

template<class InputIterator, unsigned WSize, unsigned Step = 1, class Bottom = bottom>
typedef HIDDEN tool::window< InputIterator, WSize, Step, Bottom >::exact_type

This template instantiation's exact type.

Reimplemented from tool::iterator< Bottom >.

template<class InputIterator, unsigned WSize, unsigned Step = 1, class Bottom = bottom>
typedef HIDDEN tool::window< InputIterator, WSize, Step, Bottom >::value_type

Value type of a window (std::deque<InputIterator::value_type> ).

Reimplemented from tool::iterator< Bottom >.

template<class Bottom>
typedef size_t tool::iterator< Bottom >::difference_type [inherited]

This iterator's difference type.


Constructor & Destructor Documentation

template<class I, unsigned Ws, unsigned S, class B>
template<class Iterable>
tool::window< I, Ws, S, B >::window ( Iterable &  i,
bool  end 
) [inline]

iterable -compatible constructor.


Member Function Documentation

template<class I, unsigned Ws, unsigned S, class B>
bool tool::window< I, Ws, S, B >::equal ( const window< InputIterator, WSize, Step, Bottom > &  rhs  )  const [inline]

Equality check.

See also:
iterator.

template<class I, unsigned Ws, unsigned S, class B>
void tool::window< I, Ws, S, B >::increment (  )  [inline]

Increment.

See also:
iterator.

template<class I, unsigned Ws, unsigned S, class B>
const window< I, Ws, S, B >::value_type & tool::window< I, Ws, S, B >::get (  )  const [inline]

Indirection (reference).

See also:
iterator

template<class I, unsigned Ws, unsigned S, class B>
const window< I, Ws, S, B >::value_type * tool::window< I, Ws, S, B >::get_ptr (  )  const [inline]

Indirection (pointer).

See also:
iterator

template<class I, unsigned Ws, unsigned S, class B>
const I::value_type & tool::window< I, Ws, S, B >::operator[] ( unsigned  i  )  const [inline]

Access to the window's i 'th element.

template<class Bottom>
const static_base< Bottom >::exact_type & tool::static_base< Bottom >::exact (  )  const [inline, inherited]

Safely downcast to the exact type as a const reference.

template<class Bottom>
static_base< Bottom >::exact_type & tool::static_base< Bottom >::exact (  )  [inline, inherited]

Safely downcast to the exact type as a non-const reference.

template<class Bottom>
const static_base< Bottom >::exact_type * tool::static_base< Bottom >::exact_ptr (  )  const [inline, inherited]

Safely downcast to the exact type as a const pointer.

template<class Bottom>
static_base< Bottom >::exact_type * tool::static_base< Bottom >::exact_ptr (  )  [inline, inherited]

Safely downcast to the exact type as a non-const pointer.


Member Data Documentation

template<class InputIterator, unsigned WSize, unsigned Step = 1, class Bottom = bottom>
bool tool::window< InputIterator, WSize, Step, Bottom >::at_end_ [protected]

Is this window the last one.

template<class InputIterator, unsigned WSize, unsigned Step = 1, class Bottom = bottom>
InputIterator tool::window< InputIterator, WSize, Step, Bottom >::next_ [protected]

Iterator to the next element to retrieve.

template<class InputIterator, unsigned WSize, unsigned Step = 1, class Bottom = bottom>
InputIterator tool::window< InputIterator, WSize, Step, Bottom >::last_ [protected]

Iterator past the last element.

template<class InputIterator, unsigned WSize, unsigned Step = 1, class Bottom = bottom>
value_type tool::window< InputIterator, WSize, Step, Bottom >::v_ [protected]

Current window value.


The documentation for this struct was generated from the following files:
Generated on Wed Sep 12 16:02:47 2007 for trace-tools by  doxygen 1.5.3