import type { Cont, TraversalFn, VisitResult } from "@tsplus/stdlib/collections/HashMap/_internal/hashMap" import { visitLazy as visitLazyInternal, visitLazyChildren as visitLazyChildrenInternal } from "@tsplus/stdlib/collections/HashMap/_internal/hashMap" import type { Node } from "@tsplus/stdlib/collections/HashMap/_internal/node" import { ArrayNode, canEditNode as canEditNodeInternal, CollisionNode, EmptyNode, IndexedNode, isEmptyNode as isEmptyNodeInternal, isLeafNode as isLeafNodeInternal, LeafNode } from "@tsplus/stdlib/collections/HashMap/_internal/node" export { Node } from "@tsplus/stdlib/collections/HashMap/_internal/node" /** * @tsplus static HashMap.Node.Ops empty */ export function emptyNode(): Node { return new EmptyNode() } /** * @tsplus static HashMap.Node.Ops leaf */ export function leafNode( edit: number, hash: number, key: K, value: Maybe ): Node { return new LeafNode(edit, hash, key, value) } /** * @tsplus static HashMap.Node.Ops collision */ export function collisionNode( edit: number, hash: number, children: Array> ): Node { return new CollisionNode(edit, hash, children) } /** * @tsplus static HashMap.Node.Ops indexed */ export function indexedNode( edit: number, mask: number, children: Array> ): Node { return new IndexedNode(edit, mask, children) } /** * @tsplus static HashMap.Node.Ops array */ export function arrayNode( edit: number, size: number, children: Array> ): Node { return new ArrayNode(edit, size, children) } // ----------------------------------------------------------------------------- // Type Guards // ----------------------------------------------------------------------------- /** * @tsplus static HashMap.Node.Ops isEmptyNode */ export const isEmptyNode = isEmptyNodeInternal /** * @tsplus static HashMap.Node.Ops isLeafNode */ export const isLeafNode = isLeafNodeInternal // ----------------------------------------------------------------------------- // Operations // ----------------------------------------------------------------------------- /** * @tsplus pipeable HashMap.Node canEdit */ export function canEditNode(edit: number) { return (node: Node): boolean => canEditNodeInternal(node, edit) } /** * @tsplus pipeable HashMap.Node visitLazy */ export function visitLazy(f: TraversalFn, cont?: Cont) { return (node: Node): Maybe> => visitLazyInternal(node, f) } /** * @tsplus fluent HashMap.Node.Ops visitLazyChildren */ export const visitLazyChildren = visitLazyChildrenInternal