UNPKG

@toolbox-ts/dsa

Version:
32 lines 966 B
import { Manager as NodeManager } from "../_Manager/index.js"; /** * Creates a singly linked list node manager with anchor and pointer management. * Provides methods for node creation, pointer mutation, unlinking, and traversal. * * @template AK - Anchor key string type * @template D - Data type stored in the node * @param cfg - Configuration object for anchors and node creation * @returns An API for managing singly linked list nodes */ export const create = (cfg) => { const { anchors, createNode, pointerKeys, type, setPointer } = NodeManager.create({ ...cfg, type: "singly", pointerKeys: ["next"], }); const api = { setPointer, create: createNode, get type() { return type; }, get anchors() { return anchors; }, get pointerKeys() { return pointerKeys; }, }; return api; }; //# sourceMappingURL=singly.js.map