Skip to content

graph const_iterator

Ned Bingham edited this page Apr 2, 2017 · 2 revisions

std/graph.h


graph

  • struct const_iterator

Points to a node in a graph.

Member Types

  • typedef value_type type so that generic wrappers can access the parent container's value_type

Member Variables

  • const graph<value_type> *root is a pointer to the parent container.
  • const end_node *loc is the node pointed to by this iterator.

Member Functions

Constructor

const_iterator()

The default constructor. root and loc are both set to NULL.

const_iterator(graph<value_type> *root, end_node *loc)

This sets root and loc directly. It's protected member that should only be used by the parent container.

const_iterator(const const_iterator &copy)

A copy constructor that sets root and loc.

Utility

operator bool() checks whether this iterator points to a valid node in the graph.

Accessors

value_type &operator*() returns this iterator's value.

value_type *operator->() The dot operator for this iterator's value.

value_type *ptr() returns a pointer to this iterator's value.

value_type &get() returns this iterator's value.

int idx() returns the current index of this iterator.

Iteration

iterator &operator++() Increments the iterator to the next item.

iterator &operator--() Decrements the iterator to the previous item.

iterator &operator+=(int n) Increments the iterator by n.

iterator &operator-=(int n) Decrements the iterator by n.

iterator operator+(int n) Returns the iterator n elements ahead of this one.

iterator operator-(int n) Returns the iterator n elements behind this one.

links &next() Return the proceeding nodes in the graph from this iterator.

links &prev() Return the preceding nodes in the graph from this iterator.

Comparison

bool operator==(iterator i)
bool operator!=(iterator i)
bool operator<(iterator i)
bool operator>(iterator i)
bool operator<=(iterator i)
bool operator>=(iterator i)
bool operator==(const_iterator i)
bool operator!=(const_iterator i)
bool operator<(const_iterator i)
bool operator>(const_iterator i)
bool operator<=(const_iterator i)
bool operator>=(const_iterator i)

Comparison operations between iterators compares index.

int operator-(iterator i)
int operator-(const_iterator i)

Returns the number of elements between i and this iterator by subtracting indices.

Modifiers

iterator &operator=(const iterator &copy)

set the root and loc of this iterator equal to that of another.

Simple Containers

Standard Containers

Interface Containers

Specialized Containers

Input/Output

Algorithm

Clone this wiki locally