Safe Haskell | Safe-Infered |
---|
Space efficient bit arrays
The module is meant to be imported qualified (as it is common with collection libraries).
- 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 -> aSource
Right fold over the set, including indexes of each value.
asString :: Char -> Char -> BitArray -> StringSource
Converts a bit array into a string, given characters
for 0
and 1
/
(!) :: BitArray -> Int -> BoolSource
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 BitArraySource
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 -> BitArraySource
An intersection of two bit arrays. The length of the result is the minimum length of the two.