Stacks and queues

Data structures with access limited to provide a specific way of interaction with their elements.

Import alias 'ads-js/queues'

This group contains data structures based on ordinary JavaScript Arrays as well as on linked lists from this package. Most of them are focused primarily on direct access to the stored elements without adapters akin Position. The only structure which still uses Locators is AdaptableHeapPriorityQueue.

Table of contents

LinkedStack - container of elements that are inserted and removed according to the LIFO principle. This structure is based on SinglyLinkedList.

LinkedQueue - container of elements that are inserted and removed according to the FIFO principle. This structure is based on SinglyLinkedList.

LinkedDeque - container of elements that are inserted and removed on either side. This structure is based on DoublyLinkedList.

CircularQueue - container of elements in which operations are performed based on FIFO principle and the last position is connected back to the first position to make a circle. This structure is based on CircularlyLinkedList.

CircularArrayBuffer - array-based implementation of circular FIFO data structure.

UnsortedPriorityQueue - container of elements which grants access to the least item stored in linear time and takes constant time for insertion. This structure is based on DoublyLinkedList.

SortedPriorityQueue - container of elements which grants access to the least item stored in constant time and takes linear time for insertion. This structure is based on DoublyLinkedList.

AdaptableHeapPriorityQueue - container of elements which grants access to the least item stored in logarithmic time. Insertion operation has logarithmic complexity as well. This structure is based on binary heap and can afford constant time insertion if all queued elements are given in advance. It also allows to update elements after insertion and keeps itself sorted.

Last updated

Was this helpful?