feat(data-structures/unstable): add Deque#7019
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7019 +/- ##
==========================================
+ Coverage 93.73% 93.77% +0.03%
==========================================
Files 620 621 +1
Lines 49388 49681 +293
Branches 8651 8713 +62
==========================================
+ Hits 46293 46586 +293
Misses 3025 3025
Partials 70 70 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
JS array has |
Added benchmarks in the description |
kt3k
left a comment
There was a problem hiding this comment.
Thanks for adding benchmarks!
Now Deque looks a meaningful addition. LGTM
Deque (double-ended queue) is a standard data structure in many ecosystems (e.g. Rust’s VecDeque, npm’s Denque with ~73M monthly downloads).
Potential std consumers:
Channel,binary-search-tree,untar-streamand moreBench
Array.push()/Array.pop()is extremely optimized in V8. If you only need a stack (push/pop from one end), use a plain Array.Array.unshift()andArray.shift()is slow because the engine must move all elements. Deque's ring buffer makes these very fast.The most common real-world use case for a Deque is a queue (push back + pop front) . This is where it shines 🚀
✅ = Deque faster, ❌ = Array faster. Multiplier is relative speed (e.g. "5.6× ✅" means Deque is 5.6× faster).
Results are from a M1 MacBook pro. 30 warmup + 100 measured runs per cell.