bitvec-0.2.0.1: Unboxed bit vectors

Safe HaskellNone
LanguageHaskell2010

Data.Vector.Unboxed.Mutable.Bit

Synopsis

Documentation

wordSize :: Int Source #

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

wordLength :: MVector s Bit -> Int Source #

Get the length of the vector that would be created by cloneToWords

cloneFromWords :: PrimMonad m => Int -> MVector (PrimState m) Word -> m (MVector (PrimState m) Bit) Source #

Clone a specified number of bits from a vector of words into a new 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.

cloneToWords :: PrimMonad m => MVector (PrimState m) Bit -> m (MVector (PrimState m) Word) Source #

clone a vector of bits to a new unboxed vector of words. If the bits don't completely fill the words, the last word will be zero-padded.

readWord :: PrimMonad m => MVector (PrimState m) Bit -> Int -> m Word Source #

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.

writeWord :: PrimMonad m => MVector (PrimState m) Bit -> Int -> Word -> m () Source #

write 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 word is truncated and as many low-order bits as possible are written.

mapMInPlaceWithIndex :: PrimMonad m => (Int -> Word -> m Word) -> MVector (PrimState m) Bit -> m () Source #

Map a function over a bit vector one Word at a time (wordSize bits at a time). The function will be passed the bit index (which will always be wordSize-aligned) and the current value of the corresponding word. The returned word will be written back to the vector. If there is a partial word at the end of the vector, it will be zero-padded when passed to the function and truncated when the result is written back to the array.

mapMInPlace :: PrimMonad m => (Word -> m Word) -> MVector (PrimState m) Bit -> m () Source #

Same as mapMInPlaceWithIndex but without the index.

mapInPlace :: PrimMonad m => (Word -> Word) -> MVector (PrimState m) Bit -> m () Source #

zipInPlace :: PrimMonad m => (Word -> Word -> Word) -> MVector (PrimState m) Bit -> Vector Bit -> m () Source #

invertInPlace :: PrimMonad m => MVector (PrimState m) Bit -> m () Source #

Flip every bit in the given vector

countBits :: PrimMonad m => MVector (PrimState m) Bit -> m Int Source #

return the number of ones in a bit vector

and :: PrimMonad m => MVector (PrimState m) Bit -> m Bool Source #

Returns True if all bits in the vector are set

or :: PrimMonad m => MVector (PrimState m) Bit -> m Bool Source #

Returns True if any bit in the vector is set

any :: PrimMonad m => (Bit -> Bool) -> MVector (PrimState m) Bit -> m Bool Source #

all :: PrimMonad m => (Bit -> Bool) -> MVector (PrimState m) Bit -> m Bool Source #