Iterator type used by sparse_group & sparse_table. More...
#include <ash/impl/sparse_group.h>
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 | |
iterator & | operator+= (size_type t) |
Assignment addition (position). | |
iterator & | operator-= (size_type t) |
Assignment subtration (position). | |
iterator & | operator++ () |
Pre-increment. | |
iterator | operator++ (int) |
Post-increment. | |
iterator & | operator-- () |
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. |
Iterator type used by sparse_group & sparse_table.
Table | The 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).
ash::table_iterator< Table >::table_iterator | ( | ) | [inline] |
Default constructor.
ash::table_iterator< Table >::table_iterator | ( | Table * | tbl, |
size_type | p | ||
) | [inline] |
"Real" constructor.
tbl | A pointer to the container. |
p | The current position. |
iterator ash::table_iterator< Table >::operator+ | ( | difference_type | i | ) | const [inline] |
Addition (position).
iterator& ash::table_iterator< Table >::operator++ | ( | ) | [inline] |
Pre-increment.
iterator ash::table_iterator< Table >::operator++ | ( | int | ) | [inline] |
Post-increment.
iterator& ash::table_iterator< Table >::operator+= | ( | size_type | t | ) | [inline] |
Assignment addition (position).
iterator ash::table_iterator< Table >::operator- | ( | difference_type | i | ) | const [inline] |
Subtraction (position).
difference_type ash::table_iterator< Table >::operator- | ( | iterator | it | ) | const [inline] |
Subtraction (distance).
iterator& ash::table_iterator< Table >::operator-- | ( | ) | [inline] |
Pre-decrement.
iterator ash::table_iterator< Table >::operator-- | ( | int | ) | [inline] |
Post-decrement.
iterator& ash::table_iterator< Table >::operator-= | ( | size_type | t | ) | [inline] |
Assignment subtration (position).
bool ash::table_iterator< Table >::operator< | ( | const iterator & | it | ) | const [inline] |
Less than operator.
bool ash::table_iterator< Table >::operator== | ( | const iterator & | it | ) | const [inline] |
Equality operator.
reference ash::table_iterator< Table >::operator[] | ( | difference_type | n | ) | const [inline] |
Element Access.
n | The position of the element relative to the iterator. |
© 2012 | Licensed under | Hosted by | Generated by 1.7.4 |