Description
This module provides an implementation of a First-In, First-Out (FIFO) queue based on Okasaki's "Purely Functional Data Structures." Ch.3. This Okasaki Queue version data structure ensures amortized constant-time performance for basic operations such as push, pop, and front. The Okasaki Queue consists of two lists (front and back) to separate the concerns of adding and removing elements for ensuring efficient performance.
Definitions
pop {A} (queue : Queue A) : Maybe (Pair A (Queue A))Source#
𝒪(n) worst-case, but 𝒪(1) amortized. Returns the first element and the
pushMany {A} (list : List A) (queue : Queue A) : Queue ASource#
𝒪(n). Adds a list of elements to the end of the Queue.
instance showQueueI {A} {{Show A}} : Show (Queue A)Source#