From 04c2a809377994a5e662c5c695cee6437aa8090c Mon Sep 17 00:00:00 2001 From: buttercat1791 Date: Sat, 8 Mar 2025 12:39:02 -0600 Subject: [PATCH] Define a nested Cursor class for tree iteration --- src/lib/data_structures/publication_tree.ts | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/lib/data_structures/publication_tree.ts b/src/lib/data_structures/publication_tree.ts index 9862608..080a8db 100644 --- a/src/lib/data_structures/publication_tree.ts +++ b/src/lib/data_structures/publication_tree.ts @@ -249,4 +249,36 @@ export class PublicationTree implements AsyncIterable { } // #endregion + + // #region Iteration Cursor + + // TODO: Flesh out this class. + Cursor = class { + private tree: PublicationTree; + private currentNode: PublicationTreeNode | null | undefined; + + constructor(tree: PublicationTree, currentNode: PublicationTreeNode | null = null) { + this.tree = tree; + + if (!currentNode) { + this.currentNode = this.tree.bookmark + ? this.tree.nodes.get(this.tree.bookmark) + : null; + } + } + + firstChild(): PublicationTreeNode | null { + + } + + nextSibling(): PublicationTreeNode | null { + + } + + parent(): PublicationTreeNode | null { + + } + }; + + // #endregion } \ No newline at end of file