Safe Haskell | Safe-Inferred |
---|
Queues implemented with two stacks to ensure fast writes.
- type LQueue a = ([a], [a])
- newLQueue :: LQueue a
- nullLQueue :: LQueue a -> Bool
- lengthLQueue :: LQueue a -> Int
- tryReadLQueue :: LQueue a -> Maybe (a, LQueue a)
- writeLQueue :: LQueue a -> a -> LQueue a
- trimLQueue :: LQueue (Maybe a) -> LQueue (Maybe a)
- dropStartLQueue :: LQueue (Maybe a) -> LQueue (Maybe a)
- lastLQueue :: LQueue (Maybe a) -> Maybe a
- toListLQueue :: LQueue a -> [a]
Documentation
nullLQueue :: LQueue a -> BoolSource
Check if the queue is empty.
lengthLQueue :: LQueue a -> IntSource
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 aSource
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 aSource
Dump all but the last written non-Nothing
element of the queue, if any.
toListLQueue :: LQueue a -> [a]Source