Navigate from a node to the next node in a depth-first pre-order traversal:
parents are visited before their children, and both are visited before the
next sibling of the parent. For example:
For the tree:
┌─┐
│1│
╭────┴─┴─────╮
┌─┴─┐ ┌─┴─┐
│1.1│ │1.2│
╭─┴───┴╮ ╭┴───┴─╮
┌──┴──┐┌──┴──┐┌──┴──┐┌──┴──┐
│1.1.1││1.1.2││1.2.1││1.2.2│
└─────┘└─────┘└─────┘└─────┘
tryDepthFirst ┊ result of
called on...┊ navigation
┈┈┈┈┈┈┈┈┈┈┈┈┈┈┼┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
“1” ┊ some(“1.1”)
“1.1” ┊ some(“1.2”)
“1.1.1” ┊ some(“1.1.2”)
“1.1.2” ┊ some(“1.2”)
“1.2” ┊ some(“1.2.1”)
“1.2.1” ┊ some(“1.2.2”)
“1.2.2” ┊ none()
Returns Option.none when the final node in the traversal has been reached.
Navigate from a node to the next node in a depth-first pre-order traversal: parents are visited before their children, and both are visited before the next sibling of the parent. For example:
Returns
Option.nonewhen the final node in the traversal has been reached.See depthFirst for an unsafe version.