Copyright | (c) Claude Heiland-Allen 2012 |
---|---|
License | BSD3 |
Maintainer | claude@mathr.co.uk |
Stability | unstable |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
Unboxed mutable bit arrays in the IO
monad.
- data IOBitArray i
- getBounds :: Ix i => IOBitArray i -> IO (i, i)
- newArray :: Ix i => (i, i) -> Bool -> IO (IOBitArray i)
- newArray_ :: Ix i => (i, i) -> IO (IOBitArray i)
- newListArray :: Ix i => (i, i) -> [Bool] -> IO (IOBitArray i)
- readArray :: Ix i => IOBitArray i -> i -> IO Bool
- writeArray :: Ix i => IOBitArray i -> i -> Bool -> IO ()
- mapArray :: Ix i => (Bool -> Bool) -> IOBitArray i -> IO (IOBitArray i)
- mapIndices :: (Ix i, Ix j) => (i, i) -> (i -> j) -> IOBitArray j -> IO (IOBitArray i)
- getElems :: Ix i => IOBitArray i -> IO [Bool]
- getAssocs :: Ix i => IOBitArray i -> IO [(i, Bool)]
- freeze :: Ix i => IOBitArray i -> IO (BitArray i)
- thaw :: Ix i => BitArray i -> IO (IOBitArray i)
- copy :: Ix i => IOBitArray i -> IO (IOBitArray i)
- fill :: Ix i => IOBitArray i -> Bool -> IO ()
- or :: Ix i => IOBitArray i -> IO Bool
- and :: Ix i => IOBitArray i -> IO Bool
- isUniform :: Ix i => IOBitArray i -> IO (Maybe Bool)
- elemIndex :: Bool -> IOBitArray Int -> IO (Maybe Int)
- fold :: Ix i => (Bool -> Bool -> Bool) -> IOBitArray i -> IO (Maybe Bool)
- map :: Ix i => (Bool -> Bool) -> IOBitArray i -> IO (IOBitArray i)
- zipWith :: Ix i => (Bool -> Bool -> Bool) -> IOBitArray i -> IOBitArray i -> IO (IOBitArray i)
- popCount :: Ix i => IOBitArray i -> IO Int
- unsafeReadArray :: Ix i => IOBitArray i -> i -> IO Bool
- unsafeGetElems :: Ix i => IOBitArray i -> IO [Bool]
- unsafeFreeze :: Ix i => IOBitArray i -> IO (BitArray i)
- unsafeThaw :: Ix i => BitArray i -> IO (IOBitArray i)
Documentation
data IOBitArray i Source
The type of mutable bit arrays in the IO
monad.
MArray-like interface.
getBounds :: Ix i => IOBitArray i -> IO (i, i) Source
Get the bounds of a bit array.
:: Ix i | |
=> (i, i) | bounds |
-> Bool | initial value |
-> IO (IOBitArray i) |
Create a new array filled with an initial value.
:: Ix i | |
=> (i, i) | bounds |
-> IO (IOBitArray i) |
Create a new array filled with unspecified initial values.
:: Ix i | |
=> (i, i) | bounds |
-> [Bool] | elems |
-> IO (IOBitArray i) |
Create a new array filled with values from a list.
writeArray :: Ix i => IOBitArray i -> i -> Bool -> IO () Source
Write to an array at an index.
mapArray :: Ix i => (Bool -> Bool) -> IOBitArray i -> IO (IOBitArray i) Source
Alias for map
.
:: (Ix i, Ix j) | |
=> (i, i) | new bounds |
-> (i -> j) | index transformation |
-> IOBitArray j | source array |
-> IO (IOBitArray i) |
Create a new array by reading from another.
Conversion to/from immutable bit arrays.
Construction
copy :: Ix i => IOBitArray i -> IO (IOBitArray i) Source
Copy an array.
Short-circuiting reductions.
or :: Ix i => IOBitArray i -> IO Bool Source
Short-circuit bitwise reduction: True when any bit is True.
and :: Ix i => IOBitArray i -> IO Bool Source
Short-circuit bitwise reduction: False when any bit is False.
elemIndex :: Bool -> IOBitArray Int -> IO (Maybe Int) Source
Look up index of first matching bit.
Note that the index type is limited to Int because there
is no unindex
method in the Ix
class.
Aggregate operations.
Bitwise reduction with an associative commutative boolean operator.
Implementation lifts from Bool
to Bits
and folds large chunks
at a time. Each bit is used as a source exactly once.
map :: Ix i => (Bool -> Bool) -> IOBitArray i -> IO (IOBitArray i) Source
Bitwise map. Implementation lifts from Bool
to Bits
and maps
large chunks at a time.
zipWith :: Ix i => (Bool -> Bool -> Bool) -> IOBitArray i -> IOBitArray i -> IO (IOBitArray i) Source
Bitwise zipWith. Implementation lifts from Bool
to Bits
and
combines large chunks at a time.
The bounds of the source arrays must be identical.
Unsafe.
unsafeReadArray :: Ix i => IOBitArray i -> i -> IO Bool Source
Read from an array at an index without bounds checking. Unsafe.
unsafeGetElems :: Ix i => IOBitArray i -> IO [Bool] Source
Get a list of all elements of an array. Unsafe when the source array can be modified later.
unsafeFreeze :: Ix i => IOBitArray i -> IO (BitArray i) Source
Snapshot the array into an immutable form. Unsafe when the source array can be modified later.
unsafeThaw :: Ix i => BitArray i -> IO (IOBitArray i) Source
Convert an array from immutable form. Unsafe to modify the result unless the source array is never used later.