next up previous contents index
Next: Node Array Data Accessor Up: Graphs and Iterators Previous: Observer Node Iterator (   Contents   Index


STL Iterator Wrapper ( STLNodeIt )

Definition

An instance it of class STLNodeIt< DataAccessor, Iter > is a STL iterator wrapper for node iterators (e.g. NodeIt, FilterNodeIt<pred,NodeIt>). It adds all type tags and methods that are necessary for STL conformance; see the standard draft working paper for details. The type tag value_type is equal to typename DataAccessor::value_type and the return value of operator*.

Class STLEdgeIt and STLAdjIt are defined analogously, i.e. can be used for edge iterators or adjacency iterators, respectively.

Precondition: The template parameter Iter must be a node iterator. DataAccessor must be a data accessor.

Note: There are specialized versions of STL wrapper iterator classes for each kind of iterator that return different LEDA graph objects.

class name operator*() returns
NodeIt_n node
EdgeIt_e edge
AdjIt_n node
AdjIt_e edge
OutAdjIt_n node
OutAdjIt_e edge
InAdjIt_n node
InAdjIt_e edge

#include < LEDA/graph/graph_iterator.h >

Creation

STLNodeIt< DataAccessor, Iter > it(DataAccessor da, const Iter& base_it)
    introduces a variable it of this class bound to da and base_it.

Operations

STLNodeIt<DataAccessor,Iter>& it = typename DataAccessor::value_type i
    assigns the value i, i.e. set(DA,it,i) will be invoked where DA is the associated data accessor and it the associated iterator.

bool it == const STLNodeIt<DataAccessor,Iter>& it2
    returns true if the associated values of it and it2 are equal, i.e. get(DA,cit)==get(DA,cit2) is true where cit is the associated iterator of it and cit2 is the associated iterator of it2 and DA is the associated data accessor.

bool it != const STLNodeIt<DataAccessor,Iter>& it2
    returns false if the associated value equals the one of the given iterator.

STLNodeIt<DataAccessor,Iter>& it.begin() resets the iterator to the beginning of the sequence.

STLNodeIt<DataAccessor,Iter>& it.last() resets the iterator to the ending of the sequence.

STLNodeIt<DataAccessor,Iter>& it.end() makes the iterators invalid, i.e. past-the-end-value.

typename DataAccessor::value_type& *it returns a reference to the associated value, which originally comes from data accessor da. If the associated iterator it is not valid, a dummy value reference is returned and should not be used.

Precondition: access(DA,it) returns a non constant reference to the data associated to it in DA. This functions is defined for all implemented data accessors (e.g. node_array_da, edge_array_da).


next up previous contents index
Next: Node Array Data Accessor Up: Graphs and Iterators Previous: Observer Node Iterator (   Contents   Index
root 2008-01-09