-
Notifications
You must be signed in to change notification settings - Fork 0
graph iterator
struct iterator
Points to a node in a graph.
-
typedef value_type type
so that generic wrappers can access the parent container'svalue_type
-
graph<value_type> *root
is a pointer to the parent container. -
end_node *loc
is the node pointed to by this iterator.
iterator()
The default constructor. root
and loc
are both set to NULL
.
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.
iterator(const iterator ©)
A copy constructor that sets root
and loc
.
operator bool()
checks whether this iterator points to a valid node in the graph.
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.
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.
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.
void drop()
This deletes the node pointed to by this iterator. This iterator is left pointing at the node before the deleted one in the node list.
value_type pop()
Same as drop()
but the removed node is returned instead of deleted.
iterator link(iterator n)
links link(links n)
create arcs from this node to the given nodes.
void unlink(iterator n)
remove any links from this node to n
.
iterator push(const value_type &value)
Creates a node and sets it using value
. The new node is then linked proceeding this node in the graph.
iterator rlink(iterator n)
create an arc from the given node to this node.
void runlink(iterator n)
Remove any links from n
to this node.
iterator rpush(const value_type &value)
Creates a node and sets it using value
. The new node is then linked preceding this node in the graph.
iterator &operator=(const iterator ©)
set the root
and loc
of this iterator equal to that of another.