libsgfc++ 2.0.1
A C++ library that uses SGFC to read and write SGF (Smart Game Format) data.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
LibSgfcPlusPlus::SgfcNodeIterator Class Reference

The SgfcNodeIterator class encapsulates reusable algorithms for iterating over a tree of ISgfcNode objects. More...

#include <SgfcNodeIterator.h>

Public Member Functions

 SgfcNodeIterator ()
 Initializes a newly constructed SgfcNodeIterator object.
 
virtual ~SgfcNodeIterator ()
 Destroys and cleans up the SgfcNodeIterator object.
 
void IterateOverNodesDepthFirst (std::shared_ptr< ISgfcNode > startNode, NodeVisitCallback nodeVisitCallback) const
 Iterates over the tree of nodes depth-first, starting with startNode. Invokes nodeVisitCallback whenever a node is visited. nodeVisitCallback must not be nullptr.
 

Detailed Description

The SgfcNodeIterator class encapsulates reusable algorithms for iterating over a tree of ISgfcNode objects.

Member Function Documentation

◆ IterateOverNodesDepthFirst()

void LibSgfcPlusPlus::SgfcNodeIterator::IterateOverNodesDepthFirst ( std::shared_ptr< ISgfcNode > startNode,
NodeVisitCallback nodeVisitCallback ) const

Iterates over the tree of nodes depth-first, starting with startNode. Invokes nodeVisitCallback whenever a node is visited. nodeVisitCallback must not be nullptr.

When nodeVisitCallback returns the iteration continues according to the SgfcNodeIterationContinuation value that nodeVisitCallback returns.

Does nothing if startNode is nullptr and returns immediately without invoking nodeVisitCallback.

If startNode is not nullptr then nodeVisitCallback is invoked with startNode as the parameter, after which the depth-first iteration begins.

startNode typically is the root node of a tree of nodes to be iterated. If this not the case the iteration may visit the next siblings of startNode, depending on the return value of nodeVisitCallback, but the iteration never visits the parent or previous siblings of startNode.

Exceptions
std::invalid_argumentIs thrown if nodeVisitCallback is nullptr.

The documentation for this class was generated from the following files: