Overview of data-structure-typed
mainWhat is data-structure-typed?
data-structure-typed is a library providing a comprehensive set of specialized data structures for JavaScript and TypeScript. It aims to fill the gap in the JS/TS standard library by offering high-performance, standardized implementations of structures that are typically missing or inefficiently simulated using built-in Array or Map objects.
Key Problem Solved: Efficient Alternatives to Array/Map
In standard JS/TS, developers often use Array to simulate other structures, which can lead to performance bottlenecks:
- Queue/Deque: Using
Array.shift()results in $O(n)$ time complexity. This library providesQueueandDequewith $O(1)$ enqueue and dequeue operations. - HashMap: The built-in
Mapis aLinkedHashMap(preserving insertion order), which can be slower than a pureHashMap. This library provides a dedicatedHashMapfor algorithm acceleration.
Supported Data Structures
The library includes several advanced structures:
- Heap / Priority Queue: Supports $O(\log n)$ insertion, deletion, and search, with $O(1)$ access to the extremum (min/max).
- Red Black Tree: A balanced binary search tree providing optimal performance for CRUD operations.
- Linked List: Useful for efficient insertions or deletions at a known index within an ordered set.
- Trie: Optimized for high-speed string searching and efficient string storage.
- Graph: For modeling complex relationships between nodes.
- Stack: While
Arraycan be used, this library provides a formal implementation.