bitvec-0.1.0.1: Unboxed vectors of bits / dense IntSets

Data.Vector.Unboxed.Bit

Synopsis

# Documentation

module Data.Bit

The number of `Bit`s in a `Word`. A handy constant to have around when defining `Word`-based bulk operations on bit vectors.

Given a number of bits and a vector of words, concatenate them to a vector of bits (interpreting the words in little-endian order, as described at `indexWord`). If there are not enough words for the number of bits requested, the vector will be zero-padded.

Given a vector of bits, extract an unboxed vector of words. If the bits don't completely fill the words, the last word will be zero-padded.

read a word at the given bit offset in little-endian order (i.e., the LSB will correspond to the bit at the given address, the 2's bit will correspond to the address + 1, etc.). If the offset is such that the word extends past the end of the vector, the result is zero-padded.

zipWords :: (Word -> Word -> Word) -> Vector Bit -> Vector Bit -> Vector BitSource

`zipWords f xs ys` = `fromWords (min (length xs) (length ys)) (zipWith f (toWords xs) (toWords ys))`

Flip every bit in the given vector

select :: (Vector v1 Bit, Vector v2 t) => v1 Bit -> v2 t -> [t]Source

Given a vector of bits and a vector of things, extract those things for which the corresponding bit is set.

For example, `select (V.map (fromBool . p) x) x == V.filter p x`.

exclude :: (Vector v1 Bit, Vector v2 t) => v1 Bit -> v2 t -> [t]Source

Given a vector of bits and a vector of things, extract those things for which the corresponding bit is unset.

For example, `exclude (V.map (fromBool . p) x) x == V.filter (not . p) x`.

return the number of ones in a bit vector

`True` if all bits in the vector are set

`True` if any bit in the vector is set

any :: Num a => (a -> Bool) -> Vector Bit -> BoolSource

all :: Num a => (a -> Bool) -> Vector Bit -> BoolSource

Return the address of the first bit in the vector with the specified value, if any

findIndex :: Num a => (a -> Bool) -> Vector Bit -> Maybe IntSource