d-ary-heap 2.5.0 โ†’ 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +30 -29
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,24 +1,26 @@
1
1
  ![TypeScript](https://img.shields.io/badge/TypeScript-5.3-blue.svg)
2
2
  ![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-green.svg)
3
3
 
4
- # d-Heap Priority Queue (TypeScript) v2.5.0
4
+ # d-Heap Priority Queue (TypeScript) v2.6.0
5
5
 
6
- A high-performance, generic d-ary heap priority queue with O(1) item lookup, supporting both min-heap and max-heap behavior.
6
+ **Wikipedia-standard d-ary heap** with configurable arity, O(1) item lookup, and zero-cost comparison-count instrumentation. Cross-language API parity with C++, Go, Rust, and Zig.
7
7
 
8
- **[Live Demo](https://pcfvw.github.io/d-Heap-priority-queue/)** โ€” Interactive visualization with Dijkstra's algorithm
8
+ ## ๐ŸŽฌ See it in action
9
9
 
10
- ## Strengths
10
+ **[Interactive demo โ†’](https://pcfvw.github.io/d-Heap-priority-queue/)**
11
11
 
12
- - **Flexible behavior**: min-heap or max-heap via comparator functions, and configurable arity `d` at construction time.
13
- - **Efficient operations** on n items:
14
- - O(1): access the highest-priority item (`front()`, `peek()`).
15
- - O(log_d n): `insert()` and upward reheapification.
16
- - O(d ยท log_d n): delete-top (`pop()`), with up to d children examined per level.
17
- - **O(1) item lookup**: internal Map tracks positions by item key, enabling efficient priority updates.
18
- - **Practical API**: `insert`, `front`, `peek`, `pop`, `increasePriority`, `decreasePriority`, `updatePriority`, `isEmpty`, `len`, `contains`.
19
- - **Unified API**: Cross-language standardized methods matching C++, Rust, and Zig implementations.
20
- - **TypeScript-native**: Full type safety, generics, and IDE support.
21
- - **Zero dependencies**: No runtime dependencies.
12
+ Watch the heap tree update as items are inserted, popped, and re-prioritized. Toggle arity (d=2 / d=4 / d=8) to see how tree depth changes. Step through Dijkstra's algorithm on a weighted graph, or run **race mode** to compare all three arities side-by-side. Built with React Flow; runs in the browser, no install.
13
+
14
+ ## Why this crate?
15
+
16
+ If you already know you want a priority queue, here's what `d-ary-heap` gives you over `js-priority-queue`, `priority-queue`, and other npm alternatives:
17
+
18
+ - **Configurable arity `d`** (not just d=2). Pick `d=4` for cache-friendlier inserts, `d=8` for very insert-heavy workloads.
19
+ - **O(1) item lookup + priority updates.** `increasePriority(item)`, `decreasePriority(item)`, `updatePriority(item)` โ€” the operations Dijkstra and A\* actually need. Most npm priority-queue packages don't expose these.
20
+ - **Zero-cost comparison-count instrumentation** (in the library since v2.4.0; cross-language identical since v2.6.0). Opt-in `instrumentComparator(...)` + `onBeforeOperation` / `onAfterOperation` heap hooks; JIT-elided when not in use. See [Instrumentation](#instrumentation-v240) below.
21
+ - **Cross-language API parity** with Rust, Go, C++, and Zig โ€” same method names, same complexity guarantees, **byte-for-byte identical comparison counts** on shared benchmarks (verified across 24 cells ร— 5 languages).
22
+ - **Zero runtime dependencies. Full TypeScript types.**
23
+ - **Published numbers**: see [`benchmarks/`](https://github.com/PCfVW/d-Heap-priority-queue/tree/master/benchmarks) for cross-language Dijkstra benchmarks (24 cells ร— 5 languages) and the [methodology](https://github.com/PCfVW/d-Heap-priority-queue/blob/master/benchmarks/methodology.md).
22
24
 
23
25
  ## Installation
24
26
 
@@ -232,15 +234,15 @@ For a d-ary heap with n elements:
232
234
 
233
235
  ### Cross-Language Consistency
234
236
 
235
- Currently, instrumentation is implemented in TypeScript only. The table below shows the idiomatic zero-cost approach for each language, planned for v2.5.0:
237
+ Instrumentation is implemented in **all five languages** with **byte-for-byte identical comparison counts** (verified across 24 (graph, arity) cells; see [benchmarks/README.md](https://github.com/PCfVW/d-Heap-priority-queue/blob/master/benchmarks/README.md)). Each language uses its idiomatic zero-cost mechanism:
236
238
 
237
- | Language | Mechanism | Overhead When Disabled | Status |
238
- |------------|----------------------------------|------------------------|--------|
239
- | TypeScript | Optional hooks + instrumented comparator | Zero (JIT optimization) | โœ… Implemented |
240
- | Go | Nil stats pointer | ~1 cycle (nil check) | Planned v2.5.0 |
241
- | Rust | Generic over StatsCollector trait | Zero (monomorphization) | Planned v2.5.0 |
242
- | C++ | Template policy class | Zero (inlining) | Planned v2.5.0 |
243
- | Zig | Comptime bool parameter | Zero (branch elimination) | Planned v2.5.0 |
239
+ | Language | Mechanism | Overhead When Disabled |
240
+ |------------|-------------------------------------------------|------------------------|
241
+ | TypeScript | Optional hooks + instrumented comparator | Zero (JIT optimization) |
242
+ | Go | Nil stats pointer | ~1 cycle (nil check) |
243
+ | Rust | Generic over `StatsCollector` trait | Zero (monomorphization + ZST layout) |
244
+ | C++ | Template policy class + `[[no_unique_address]]` | Zero (inlining + ZST collapse) |
245
+ | Zig | Comptime bool parameter on `DHeapWithStats` | Zero (branch elimination + `void` field type) |
244
246
 
245
247
  ## Priority Update Semantics
246
248
 
@@ -261,14 +263,9 @@ This library uses **importance-based** semantics:
261
263
 
262
264
  ## Performance
263
265
 
264
- ### Benchmark Results (Node.js v20, typical hardware)
266
+ ### Benchmarks
265
267
 
266
- | Operation | d=2 | d=4 | d=8 |
267
- |-----------|-----|-----|-----|
268
- | 100k inserts | ~21ms | ~13ms | ~11ms |
269
- | 100k pops | ~187ms | ~136ms | ~140ms |
270
- | Throughput (insert) | ~2.2M ops/sec | | |
271
- | Throughput (pop+insert) | ~900k ops/sec | | |
268
+ See [`benchmarks/`](https://github.com/PCfVW/d-Heap-priority-queue/tree/master/benchmarks) for the Phase 3 cross-language Dijkstra sweep (24 cells ร— 5 languages, K=2 warmup + 10 timed reps each, median + IQR reporting). On AMD Ryzen 9 5950X with Node v24.11.1, the TypeScript example runs `huge_dense ร— d=8` (75 936 heap comparisons) at a median of **13.4 ms (~177 ns/cmp)** โ€” within 25% of Go's 11.0 ms / 145 ns/cmp on the same workload. The full methodology is in [`benchmarks/methodology.md`](https://github.com/PCfVW/d-Heap-priority-queue/blob/master/benchmarks/methodology.md).
272
269
 
273
270
  ### Performance Tips
274
271
 
@@ -324,3 +321,7 @@ npm run typecheck
324
321
  ## Reference
325
322
 
326
323
  Section A.3, [d-Heaps](https://en.wikipedia.org/wiki/D-ary_heap), pp. 773โ€“778 of Ravindra Ahuja, Thomas Magnanti & James Orlin, **Network Flows** (Prentice Hall, 1993).
324
+
325
+ ## License
326
+
327
+ Apache License 2.0 โ€” See [LICENSE](https://github.com/PCfVW/d-Heap-priority-queue/blob/master/LICENSE) for details.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "d-ary-heap",
4
- "version": "2.5.0",
4
+ "version": "2.6.0",
5
5
  "description": "High-performance d-ary heap priority queue with O(1) item lookup, configurable arity, and min/max heap support",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.js",