containers-0.6.7: Assorted concrete container types

Copyright | (c) David Feuer 2016
License | BSD-style
Maintainer | libraries@haskell.org
Portability | portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

Utils.Containers.Internal.BitQueue

Description

# WARNING

This module is considered internal.

The Package Versioning Policy does not apply.

The contents of this module may change in any way whatsoever and without any warning between minor versions of this package.

Authors importing this module are expected to track development closely.

# Description

An extremely light-weight, fast, and limited representation of a string of up to (2*WORDSIZE - 2) bits. In fact, there are two representations, misleadingly named bit queue builder and bit queue. The builder supports only `emptyQB`, creating an empty builder, and `snocQB`, enqueueing a bit. The bit queue builder is then turned into a bit queue using `buildQ`, after which bits can be removed one by one using `unconsQ`. If the size limit is exceeded, further operations will silently produce nonsense.

Synopsis

- data BitQueue
- data BitQueueB
- emptyQB :: BitQueueB
- snocQB :: BitQueueB -> Bool -> BitQueueB
- buildQ :: BitQueueB -> BitQueue
- unconsQ :: BitQueue -> Maybe (Bool, BitQueue)
- toListQ :: BitQueue -> [Bool]

# Documentation

data BitQueue Source #

#### Instances

Instances details

Show BitQueue Source # |
Instance details Defined in Utils.Containers.Internal.BitQueue Methods showsPrec :: Int -> BitQueue -> ShowS Source # show :: BitQueue -> String Source # showList :: [BitQueue] -> ShowS Source #

data BitQueueB Source #

#### Instances

Instances details

Show BitQueueB Source # |
Instance details Defined in Utils.Containers.Internal.BitQueue Methods showsPrec :: Int -> BitQueueB -> ShowS Source # show :: BitQueueB -> String Source # showList :: [BitQueueB] -> ShowS Source #

emptyQB :: BitQueueB Source #

Create an empty bit queue builder. This is represented as a single guard bit in the most significant position.

snocQB :: BitQueueB -> Bool -> BitQueueB Source #

Enqueue a bit. This works by shifting the queue right one bit, then setting the most significant bit as requested.

buildQ :: BitQueueB -> BitQueue Source #

Convert a bit queue builder to a bit queue. This shifts in a new guard bit on the left, and shifts right until the old guard bit falls off.

unconsQ :: BitQueue -> Maybe (Bool, BitQueue) Source #

Dequeue an element, or discover the queue is empty.

toListQ :: BitQueue -> [Bool] Source #

Convert a bit queue to a list of bits by unconsing. This is used to test that the queue functions properly.