feat(data-structures/unstable): add MultiMap#7100
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7100 +/- ##
==========================================
+ Coverage 94.51% 94.53% +0.02%
==========================================
Files 630 631 +1
Lines 50970 51165 +195
Branches 9090 9127 +37
==========================================
+ Hits 48175 48371 +196
Misses 2224 2224
+ Partials 571 570 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
bartlomieju
left a comment
There was a problem hiding this comment.
Nice work — well-documented, well-tested, and covers a real gap. A few things to address:
valueCount getter
size counting distinct keys follows Map convention, but multimap users very commonly need total value count. Consider adding a valueCount getter, cheaply maintained with an internal counter (increment in add, decrement in deleteEntry, reset in clear/delete). Without it the only way is to iterate everything.
Deno.customInspect
Not a blocker (other unstable data structures don't have it either), but [Symbol.for("Deno.customInspect")] would improve DX — console.log(multimap) would show something useful rather than an opaque object.
ba137bb to
571f101
Compare
|
Thanks for the thorough review.
|
Adds
MultiMap<K, V>under@std/data-structures/unstable. It's aMap-like container where each key holds an ordered list of values.Covers the common "values keyed by group" case (e.g. parsed query strings, HTTP headers, users grouped by role) without hand-rolling
Map<K, V[]>wrappers at every call site.I plan to use it in the cache and xml module.