Options
All
  • Public
  • Public/Protected
  • All
Menu

Used for traversing tree structures in depth-first order.

The nodes being traversed must either implement the ITreeNode interface, or you can pass a callback in the constructor that should return all children for the given node.

Type parameters

Hierarchy

  • TreeNodeWalker

Implements

Index

Constructors

constructor

  • new TreeNodeWalker<T>(rootNodes: readonly ITreeNode<T>[]): TreeNodeWalker<T>
  • new TreeNodeWalker<T>(rootNodes: readonly T[], childrenCallback: (parent: T) => readonly T[]): TreeNodeWalker<T>
  • Create a new instance using the given nodes. All nodes must implement the ITreeNode interface.

    Type parameters

    Parameters

    Returns TreeNodeWalker<T>

  • Create a new instance using the given nodes. The childrenCallback will be called to get all children for a node.

    Type parameters

    Parameters

    • rootNodes: readonly T[]
    • childrenCallback: (parent: T) => readonly T[]
        • (parent: T): readonly T[]
        • Parameters

          • parent: T

          Returns readonly T[]

    Returns TreeNodeWalker<T>

Methods

advanceToNode

  • advanceToNode(node: T): void

hasNext

  • hasNext(): boolean
  • If there are more content blocks to visit by calling next()

    Returns boolean

next

  • next(): T
  • Returns the next node in depth-first order. Calling this method if hasNext() return false will throw an error.

    Returns T

Generated using TypeDoc