Safe Haskell | None |
---|
Space efficient bit arrays
The module is meant to be imported qualified (as it is common with collection libraries).
Synopsis
- data BitArray = BitArray {
- size :: !Int
- _bitArrayBits :: !IntSet
- empty :: BitArray
- zeroes :: Int -> BitArray
- foldr :: (Bool -> Int -> a -> a) -> a -> BitArray -> a
- asString :: Char -> Char -> BitArray -> String
- count0 :: BitArray -> Int
- count1 :: BitArray -> Int
- (!) :: BitArray -> Int -> Bool
- setAt :: (MonadError e m, Error e) => Int -> Bool -> BitArray -> m BitArray
- (-&-) :: BitArray -> BitArray -> BitArray
- (-|-) :: BitArray -> BitArray -> BitArray
- subset :: BitArray -> BitArray -> Bool
- toList :: BitArray -> [Bool]
- fromList :: [Bool] -> BitArray
Documentation
A fixed-size, space-efficient array of bits.
BitArray | |
|
foldr :: (Bool -> Int -> a -> a) -> a -> BitArray -> a Source #
Right fold over the set, including indexes of each value.
asString :: Char -> Char -> BitArray -> String Source #
Converts a bit array into a string, given characters
for 0
and 1
/
(!) :: BitArray -> Int -> Bool infixl 9 Source #
Test a given bit in an array.
If it's outside its scope, it's always False
.
setAt :: (MonadError e m, Error e) => Int -> Bool -> BitArray -> m BitArray Source #
Sets or removes an element from a bit array.
Sets a given bit in an array. Fails if the index is out of bounds.
(-&-) :: BitArray -> BitArray -> BitArray infixl 7 Source #
An intersection of two bit arrays. The length of the result is the minimum length of the two.