From 5e5462d837030ff355617910d5208c89bfcca359 Mon Sep 17 00:00:00 2001 From: Tyler Hill Date: Thu, 19 Oct 2023 10:14:53 -0500 Subject: [PATCH] Add comments to autocomplete.ts --- pages/api/autocomplete.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pages/api/autocomplete.ts b/pages/api/autocomplete.ts index 406346bc..0e9b933f 100644 --- a/pages/api/autocomplete.ts +++ b/pages/api/autocomplete.ts @@ -68,6 +68,7 @@ class PriorityQueue { } } +// bfs search from node in DAG, only until next result can be returned function bfsRecursionToNextData(queue: PriorityQueue) { const queueItem = queue.dequeue(); if (graph.getNodeAttribute(queueItem?.data?.node, 'visited')) { @@ -107,6 +108,7 @@ function bfsRecursionToNextData(queue: PriorityQueue) { return; } +// bfs search from node in DAG, adding children to priorirty queue if parant matches search string function bfsRecursion(queue: PriorityQueue) { const queueItem = queue.dequeue(); if (typeof queueItem?.data === 'undefined') { @@ -193,6 +195,7 @@ function bfsRecursion(queue: PriorityQueue) { type bfsReturn = SearchQuery | undefined; +// search autocomplete program using a DAG (more specifically a radix tree) to search for matches until limit is reached function searchAutocomplete(query: string, limit: number) { query = query.trimStart().toUpperCase(); graph.updateEachNodeAttributes((node, attr) => {