LambdaHack-0.2.10: A roguelike game engine in early and active development

Safe HaskellSafe-Infered

Game.LambdaHack.Utils.LQueue

Description

Queues implemented with two stacks to ensure fast writes.

Synopsis

Documentation

type LQueue a = ([a], [a])

Queues implemented with two stacks.

newLQueue :: LQueue a

Create a new empty mutable queue.

nullLQueue :: LQueue a -> Bool

Check if the queue is empty.

lengthLQueue :: LQueue a -> Int

The length of the queue.

tryReadLQueue :: LQueue a -> Maybe (a, LQueue a)

Try reading a queue. Return Nothing if empty.

writeLQueue :: LQueue a -> a -> LQueue a

Write to the queue. Faster than reading.

trimLQueue :: LQueue (Maybe a) -> LQueue (Maybe a)

Remove all but the last written non-Nothing element of the queue.

dropStartLQueue :: LQueue (Maybe a) -> LQueue (Maybe a)

Remove frames up to and including the first segment of Nothing frames. | If the resulting queue is empty, apply trimLQueue instead.

lastLQueue :: LQueue (Maybe a) -> Maybe a

Dump all but the last written non-Nothing element of the queue, if any.

toListLQueue :: LQueue a -> [a]