Public Types | Public Member Functions | Public Attributes | Related Functions
ash::table_iterator< Table > Struct Template Reference

Iterator type used by sparse_group & sparse_table. More...

#include <ash/impl/sparse_group.h>

List of all members.

Public Types

typedef table_iterator iterator
Iterator Traits
typedef
std::random_access_iterator_tag 
iterator_category
typedef Table::value_type value_type
typedef Table::difference_type difference_type
typedef Table::size_type size_type
typedef table_element_adaptor
< Table > 
reference
typedef table_element_adaptor
< Table > * 
pointer

Public Member Functions

void check () const
reference operator[] (difference_type n) const
 Element Access.
Constructors/Destructors

We use the default copy constructor.

We use the default destructor.

 table_iterator ()
 Default constructor.
 table_iterator (Table *tbl, size_type p)
 "Real" constructor.
Dereference Operators

The main thing our iterator does is dereference.

If the table entry we point to is empty, we return the default value type. This is the big different function from the const iterator.

reference operator* ()
pointer operator-> ()
Arithmetic Operators
iteratoroperator+= (size_type t)
 Assignment addition (position).
iteratoroperator-= (size_type t)
 Assignment subtration (position).
iteratoroperator++ ()
 Pre-increment.
iterator operator++ (int)
 Post-increment.
iteratoroperator-- ()
 Pre-decrement.
iterator operator-- (int)
 Post-decrement.
iterator operator+ (difference_type i) const
 Addition (position).
iterator operator- (difference_type i) const
 Subtraction (position).
difference_type operator- (iterator it) const
 Subtraction (distance).
Comparison Operators

We only define == and >, others are defined in std::rel_ops.

bool operator== (const iterator &it) const
 Equality operator.
bool operator< (const iterator &it) const
 Less than operator.

Public Attributes

Table * table
size_type pos

Related Functions

(Note that these are not member functions.)

template<class T >
table_iterator< T > operator+ (typename table_iterator< T >::difference_type i, table_iterator< T > it)
 Global addition operator.

Detailed Description

template<class Table>
struct ash::table_iterator< Table >

Iterator type used by sparse_group & sparse_table.

Template Parameters:
TableThe type of table we iterate through.

Our iterator as simple as iterators can be: basically it's just the index into our table. Dereference, the only complicated thing, we punt to the table class. This just goes to show how much machinery STL requires to do even the most trivial tasks.

By templatizing over Table, we have one iterator type which we can use for both sparse_tables and sparse_groups. In fact it works on any class that allows size() and operator[] (eg vector), as long as it does the standard STL typedefs too (eg value_type).


Constructor & Destructor Documentation

template<class Table >
ash::table_iterator< Table >::table_iterator ( ) [inline]

Default constructor.

template<class Table >
ash::table_iterator< Table >::table_iterator ( Table *  tbl,
size_type  p 
) [inline]

"Real" constructor.

Parameters:
tblA pointer to the container.
pThe current position.

Member Function Documentation

template<class Table >
iterator ash::table_iterator< Table >::operator+ ( difference_type  i) const [inline]

Addition (position).

template<class Table >
iterator& ash::table_iterator< Table >::operator++ ( ) [inline]

Pre-increment.

template<class Table >
iterator ash::table_iterator< Table >::operator++ ( int  ) [inline]

Post-increment.

template<class Table >
iterator& ash::table_iterator< Table >::operator+= ( size_type  t) [inline]

Assignment addition (position).

template<class Table >
iterator ash::table_iterator< Table >::operator- ( difference_type  i) const [inline]

Subtraction (position).

template<class Table >
difference_type ash::table_iterator< Table >::operator- ( iterator  it) const [inline]

Subtraction (distance).

template<class Table >
iterator& ash::table_iterator< Table >::operator-- ( ) [inline]

Pre-decrement.

template<class Table >
iterator ash::table_iterator< Table >::operator-- ( int  ) [inline]

Post-decrement.

template<class Table >
iterator& ash::table_iterator< Table >::operator-= ( size_type  t) [inline]

Assignment subtration (position).

template<class Table >
bool ash::table_iterator< Table >::operator< ( const iterator it) const [inline]

Less than operator.

template<class Table >
bool ash::table_iterator< Table >::operator== ( const iterator it) const [inline]

Equality operator.

template<class Table >
reference ash::table_iterator< Table >::operator[] ( difference_type  n) const [inline]

Element Access.

Parameters:
nThe position of the element relative to the iterator.

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


© 2012   AshTL
Licensed under  AGPLv3
Hosted by  Get AshTL at SourceForge.net. Fast, secure and Free Open Source software downloads
Generated by  doxygen 1.7.4