import { Concept } from "../DataStructures/Concept"; import { Node } from "./Node"; /** * BinaryTree — In-memory concept store keyed by numeric concept ID. * * Backed by a Map for O(1) lookups, inserts, and deletes. * Also maintains the BinaryCharacterTree (character-indexed) on every insert * so character-based search continues to work. * * All public method signatures are preserved for backward compatibility. * getNodeFromTree returns a { key, value } wrapper so callers that access * node.value continue to work without changes. */ export declare class BinaryTree { /** Sentinel root — non-null when the map has data, null when empty. */ static root: Node | null; /** Primary data store: concept ID → Concept object */ private static conceptMap; private static normalizeId; /** * Low-level add — stores the node's key/value in the Map. * Kept for API compatibility (called internally by addConceptToTree). * @param node - Node with numeric key and Concept value */ static addNodeToTree(node: Node): void; /** * Polls until IdentifierFlags.isDataLoaded is true (max 25 seconds). * Used by callers that need to wait for the initial IndexedDB load to finish. */ static waitForDataToLoad(): Promise; /** Recursive polling helper for waitForDataToLoad */ static checkFlag(resolve: any): any; /** * Adds a concept to both the ID map and the character tree. * * The character tree (BinaryCharacterTree) is still an AVL tree because * it supports character-based search which is out of scope for this refactor. * * @param concept - The Concept to store */ static addConceptToTree(concept: Concept): void; /** * Retrieves a concept by ID from the Map. * * Returns a { key, value } wrapper matching the Node shape that callers expect. * Callers access the returned object's .value property to get the Concept. * * @param id - The concept ID to look up * @returns Node-like wrapper with .value = Concept, or null if not found */ static getNodeFromTree(id: number): Promise; /** * Removes a concept by ID. Dispatches an event before deletion * so listeners (e.g. UI components) can react to the removal. * * @param id - The concept ID to remove */ static removeNodeFromTree(id: number): Promise; /** * Bulk concept retrieval by ID list. * * For each ID found in the Map, pushes the Concept into conceptArray * and removes the ID from the ids array. IDs remaining in the array * after this call are "not found" and will be fetched from the backend. * * Performance: O(k) where k = ids.length (was O(N) full tree traversal). * * @param ids - Array of concept IDs to look up (mutated: found IDs are spliced out) * @param conceptArray - Output array (mutated: found Concepts are pushed) * @param remainingIds - Not used directly but kept for API compatibility */ static getConceptListFromIds(ids: number[], conceptArray: Concept[], remainingIds: any): Promise; /** * Returns the total number of concepts stored. * @returns Number of concepts in the Map */ static countNumberOfNodes(): number; }