Dequeue

cats.collections.Dequeue
See theDequeue companion object
sealed abstract class Dequeue[+A]

Dequeue - A Double Ended Queue

Front Back

<- uncons --------- unsnoc -> cons -> --------- <- snoc

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. Dequeuing 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

Attributes

Companion
object
Source
Dequeue.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def backOption: Option[A]

Attributes

Source
Dequeue.scala

Attributes

Source
Dequeue.scala

Attributes

Source
Dequeue.scala

Concrete methods

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

Append another Dequeue to this dequeue

Append another Dequeue to this dequeue

Attributes

Source
Dequeue.scala
def +:[AA >: A](a: AA): Dequeue[AA]

alias for cons

alias for cons

Attributes

Source
Dequeue.scala
def :+[AA >: A](a: AA): Dequeue[AA]

alias for snoc

alias for snoc

Attributes

Source
Dequeue.scala
def coflatMap[B](f: Dequeue[A] => B): Dequeue[B]

Attributes

Source
Dequeue.scala
def cons[AA >: A](a: AA): Dequeue[AA]

enqueue to the front of the queue

enqueue to the front of the queue

Attributes

Source
Dequeue.scala
def flatMap[B](f: A => Dequeue[B]): Dequeue[B]

Attributes

Source
Dequeue.scala
def foldLeft[B](b: B)(f: (B, A) => B): B

Attributes

Source
Dequeue.scala
def foldRight[B](b: Eval[B])(f: (A, Eval[B]) => Eval[B]): Eval[B]

Attributes

Source
Dequeue.scala
def map[B](f: A => B): Dequeue[B]

Attributes

Source
Dequeue.scala
def reverse: Dequeue[A]

Attributes

Source
Dequeue.scala
def size: Int

Attributes

Source
Dequeue.scala
def snoc[AA >: A](a: AA): Dequeue[AA]

enqueue on to the back of the queue

enqueue on to the back of the queue

Attributes

Source
Dequeue.scala
def to[Col[_], AA >: A](implicit cbf: Factory[AA, Col[AA]]): Col[AA]

Attributes

Source
Dequeue.scala

Attributes

Source
Dequeue.scala
def toList: List[A]

Attributes

Source
Dequeue.scala
def uncons: Option[(A, Dequeue[A])]

destructure from the front of the queue

destructure from the front of the queue

Attributes

Source
Dequeue.scala
def unsnoc: Option[(A, Dequeue[A])]

destructure from the back of the queue

destructure from the back of the queue

Attributes

Source
Dequeue.scala