parsley-core-2.2.0.0: A fast parser combinator library backed by Typed Template Haskell
LicenseBSD-3-Clause
MaintainerJamie Willis
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Parsley.Internal.Common.RewindQueue.Impl

Description

Implementation of a FIFO queue structure, with amortized operations that also supports a rewinding operation backed by a LIFO stack.

Since: 1.5.0.0

Synopsis

Documentation

data RewindQueue a Source #

Concrete FIFO Queue, with amortized constant operations.

Also keeps history of dequeued values, which can be undone in a LIFO manner.

Since: 1.5.0.0

Constructors

RewindQueue 

Fields

Instances

Instances details
QueueLike RewindQueue Source # 
Instance details

Defined in Parsley.Internal.Common.RewindQueue

Eq a => Eq (RewindQueue a) Source # 
Instance details

Defined in Parsley.Internal.Common.RewindQueue.Impl

Show a => Show (RewindQueue a) Source # 
Instance details

Defined in Parsley.Internal.Common.RewindQueue.Impl

empty :: RewindQueue a Source #

Construct an empty queue.

Since: 1.5.0.0

enqueue :: a -> RewindQueue a -> RewindQueue a Source #

Adds an element onto the end of the queue.

Since: 1.5.0.0

enqueueAll :: [a] -> RewindQueue a -> RewindQueue a Source #

Adds each of the elements onto the queue, from left-to-right.

Since: 1.5.0.0

dequeue :: RewindQueue a -> (a, RewindQueue a) Source #

Removes an element from the front of the queue.

Since: 1.5.0.0

poke :: (a -> a) -> RewindQueue a -> (a, RewindQueue a) Source #

modifies the head of the queue, without removal. Returns the old head

Since: 2.1.0.0

rewind :: Int -> RewindQueue a -> RewindQueue a Source #

Undoes the last \(n\) dequeue operations but only if there are that many available undos. Otherwise, it will throw an error.

Since: 1.5.0.0

null :: RewindQueue a -> Bool Source #

Is the queue empty?

Since: 1.5.0.0

size :: RewindQueue a -> Int Source #

Returns how many elements are in the queue.

Since: 1.5.0.0

foldr :: (a -> b -> b) -> b -> RewindQueue a -> b Source #

Folds the values in the queue. Undo history is not included.

Since: 1.5.0.0

toList :: RewindQueue a -> [a] Source #

Converts this queue into a list. Undo history is discarded.

Since: 1.5.0.0