[Go to site: main page, start]

Class StringTree<TEntry>

A data structure representing a tree of string nodes with arbitrary object leaves.

Type Parameters

  • TEntry extends object = object

Hierarchy (View Summary)

Index

Accessors

  • get leaves(): symbol

    The key symbol that stores the leaves of any given node.

    Returns symbol

Methods

  • Insert an entry into the tree.

    Parameters

    • strings: Iterable<string, any, any>

      The string parents for the entry.

    • entry: TEntry

      The entry to store.

    Returns StringTreeNode

    The node the entry was added to.

  • Traverse the tree along the given string path and return any entries reachable from the node.

    Parameters

    • strings: Iterable<string, any, any>

      The string path to the desired node.

    • Optionaloptions: { filterEntries?: any; limit?: number } = {}
      • OptionalfilterEntries?: any

        A filter function to apply to each candidate entry.

      • Optionallimit?: number

        The maximum number of items to retrieve.

    Returns WordTreeEntry[]

  • Returns the node at the given path through the tree.

    Parameters

    • strings: string[]

      The string path to the desired node.

    • Optionaloptions: { hasLeaves?: boolean } = {}
      • OptionalhasLeaves?: boolean

        Only return the most recently visited node that has leaves, otherwise return the exact node at the prefix, if it exists.

    Returns void | StringTreeNode

  • Protected

    Perform a breadth-first search starting from the given node and retrieving any entries reachable from that node, until we reach the limit.

    Parameters

    • node: StringTreeNode

      The starting node.

    • entries: any[]

      The accumulated entries.

    • queue: StringTreeNode[]

      The working queue of nodes to search.

    • Optionaloptions: { filterEntries?: StringTreeEntryFilter; limit?: number } = {}
      • OptionalfilterEntries?: StringTreeEntryFilter

        A filter function to apply to each candidate entry.

      • Optionallimit?: number

        The maximum number of entries to retrieve before stopping.

    Returns void