import { Connection } from "../../DataStructures/Connection"; import { ConnectionNode } from "./ConnectionNode"; /** * ConnectionBinaryTree — In-memory connection store keyed by numeric connection ID. * * Backed by a Map for O(1) lookups, inserts, and deletes. * The secondary index trees (ConnectionTypeTree, ConnectionOfTheTree) are * managed separately by ConnectionData and remain unchanged. * * 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 ConnectionBinaryTree { /** Sentinel root — non-null when the map has data, null when empty. */ static connectionroot: ConnectionNode | null; /** Primary data store: connection ID → Connection object */ private static connectionMap; /** * Low-level add — stores the node's key/value in the Map. * Kept for API compatibility. * @param node - ConnectionNode with numeric key and Connection value */ static addNodeToTree(node: ConnectionNode): void; /** * Adds a connection to the Map and dispatches an event for the * owning concept so UI listeners can react. * * The dispatchIdEvent(ofTheConceptId) was previously fired inside * ConnectionNode.addNode when the node was placed into a null slot. * We only fire it for new connections (not overwrites) to preserve * the original behavior. * * @param connection - The Connection to store */ static addConnectionToTree(connection: Connection): void; /** * Returns the total number of connections stored. * @returns Number of connections in the Map */ static traverse(): number; /** * Polls until IdentifierFlags.isConnectionLoaded 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; /** * Removes a connection by ID. Dispatches an event for the owning concept * before deletion so listeners can react to the removal. * * @param id - The connection ID to remove */ static removeNodeFromTree(id: number): Promise; /** * Retrieves a connection by ID from the Map. * * Returns a { key, value } wrapper matching the ConnectionNode shape. * Also increments the connection's count field for access tracking * (preserving the original ConnectionNode.getFromNode behavior). * * @param id - The connection ID to look up * @returns ConnectionNode-like wrapper with .value = Connection, or null/undefined */ static getNodeFromTree(id: number): Promise; /** * Bulk connection retrieval by ID list. * * For each ID found in the Map, pushes the Connection into connectionArray * and removes the ID from the ids array. IDs remaining 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 connection IDs to look up (mutated: found IDs are spliced out) * @param connectionArray - Output array (mutated: found Connections are pushed) * @param remainingIds - Not used directly but kept for API compatibility */ static getConnectionListFromIds(ids: number[], connectionArray: Connection[], remainingIds: any): Promise; }