@extends('layouts.TreeContainerLibrary') @section('styles') @stop @section('panel-heading') Node Iterators @stop @section('content')

The child node iterators, node_iterator and const_node_iterator were introduced to the TCL with version 4.00. These iterators were introduced as a necessity for working with particular STL algorithms, as described below.

The child node iterators are almost identical in operation to the child element iterators. The primary difference between the two types is that the child node iterators expose the underlying node, while the child element iterators expose the underlying element. This means that the * and -> operations of the child node iterators return a pointer and reference (respecitively) to underlying node, or tree_type object. The child element iterator, on the other hand, returns a pointer and reference to a stored_type object, which is the element which resides in the node.

The signatures of these two operators are as follows.

The only other difference between the two types of iterators, is that the node() operation is not available to the child node iterators. Since the child node iterators expose the node with the dereference and pointer operators, there is no need for a node() operation.

Just as the child element iterator has access to the underlying node with the node() operation, the child node iterators can access the underlying element, with the node's get() operation. Note that this is an operation of the node, or tree_type, not an operation of the child node iterator.

Except for the differences described above, the child node iterator perform identically to the child element iterator, so see the discussion on the child element iterator for information on the child node iterator.

The reason for introducing the child node iterator in version 4.00, is to be able to use the child node iterators for particular STL algorithms. Certain STL algorithms, such as std::remove() need an iterator which exposes the underlying node rather than exposing the underlying element, to work properly. Other STL algorithms can take either type of iterator, but will behave differently depending on the type of iterator used.

The operations below, which are available for all four trees in the TCL, allow you to obtain a child node iterator from any node.

@stop