zrwusa / data-structure-typed

Javascript Data Structure & TypeScript Data Structure. Heap, Binary Tree, Red Black Tree, Linked List, Deque, Trie, HashMap, Directed Graph, Undirected Graph, Binary Search Tree, AVL Tree, Priority Queue, Graph, Queue, Tree Multiset, Singly Linked List, Doubly Linked List, Max Heap, Max Priority Queue, Min Heap, Min Priority Queue, Stack.
https://data-structure-typed-docs.vercel.app
MIT License
114 stars 8 forks source link

The performance of Queue.shift Deque.shift is slower than Array? #81

Closed zrwusa closed 7 months ago

zrwusa commented 7 months ago

Describe the bug The performance of Queue.shift and Deque.shift is slower than Array

zrwusa commented 7 months ago

Due to the fact that both Deque and Queue maintain an offset, the pop method is slightly slower than Array. However, the shift method is significantly faster by several orders of magnitude.