LambdaHack-0.4.101.0: A game engine library for roguelike dungeon crawlers

Safe HaskellSafe-Inferred
LanguageHaskell2010

Game.LambdaHack.Common.LQueue

Description

Queues implemented with two stacks to ensure fast writes.

Synopsis

Documentation

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

Queues implemented with two stacks.

newLQueue :: LQueue a Source

Create a new empty mutable queue.

nullLQueue :: LQueue a -> Bool Source

Check if the queue is empty.

lengthLQueue :: LQueue a -> Int Source

The length of the queue.

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

Try reading a queue. Return Nothing if empty.

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

Write to the queue. Faster than reading.

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

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

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

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 Source

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