Dequeue

sealed abstract
class Dequeue[A]

A Double-ended queue, based on the Bankers Double Ended Queue as described by C. Okasaki in "Purely Functional Data Structures"

A queue that allows items to be put onto either the front (cons) or the back (snoc) of the queue in constant time, and constant time access to the element at the very front or the very back of the queue. Dequeueing an element from either end is constant time when amortized over a number of dequeues.

This queue maintains an invariant that whenever there are at least two elements in the queue, neither the front list nor back list are empty. In order to maintain this invariant, a dequeue from either side which would leave that side empty constructs the resulting queue by taking elements from the opposite side

Companion
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def isEmpty: Boolean

Concrete methods

def ++(other: Dequeue[A]): Dequeue[A]

Append another Dequeue to this dequeue

Append another Dequeue to this dequeue

def +:(a: A): Dequeue[A]

alias for cons

alias for cons

def :+(a: A): Dequeue[A]

alias for snoc

alias for snoc

def cons(a: A): Dequeue[A]

enqueue to the front of the queue

enqueue to the front of the queue

def foldLeft[B](b: B)(f: (B, A) => B): B
def foldRight[B](b: B)(f: (A, B) => B): B
def map[B](f: A => B): Dequeue[B]
def size: Int
def snoc(a: A): Dequeue[A]

enqueue on to the back of the queue

enqueue on to the back of the queue

convert this queue to a list of elements from back to front

convert this queue to a list of elements from back to front

def toBackLazyList: LazyList[A]

convert this queue to a LazyList of elements from back to front

convert this queue to a LazyList of elements from back to front

def toIList: IList[A]

convert this queue to a list of elements from front to back

convert this queue to a list of elements from front to back

def toLazyList: LazyList[A]

convert this queue to a LazyList of elements from front to back

convert this queue to a LazyList of elements from front to back

def uncons: Maybe[(A, Dequeue[A])]

dequeue from the front of the queue

dequeue from the front of the queue

def unsnoc: Maybe[(A, Dequeue[A])]

dequeue from the back of the queue

dequeue from the back of the queue