Copyright | (c) Claude Heiland-Allen 2012 |
---|---|
License | BSD3 |
Maintainer | claude@mathr.co.uk |
Stability | unstable |
Portability | uses ST |
Safe Haskell | None |
Language | Haskell98 |
Unboxed mutable bit arrays in the ST
monad.
- data STBitArray s i
- getBounds :: Ix i => STBitArray s i -> ST s (i, i)
- newArray :: Ix i => (i, i) -> Bool -> ST s (STBitArray s i)
- newArray_ :: Ix i => (i, i) -> ST s (STBitArray s i)
- newListArray :: Ix i => (i, i) -> [Bool] -> ST s (STBitArray s i)
- readArray :: Ix i => STBitArray s i -> i -> ST s Bool
- writeArray :: Ix i => STBitArray s i -> i -> Bool -> ST s ()
- mapArray :: Ix i => (Bool -> Bool) -> STBitArray s i -> ST s (STBitArray s i)
- mapIndices :: (Ix i, Ix j) => (i, i) -> (i -> j) -> STBitArray s j -> ST s (STBitArray s i)
- getElems :: Ix i => STBitArray s i -> ST s [Bool]
- getAssocs :: Ix i => STBitArray s i -> ST s [(i, Bool)]
- freeze :: Ix i => STBitArray s i -> ST s (BitArray i)
- thaw :: Ix i => BitArray i -> ST s (STBitArray s i)
- copy :: Ix i => STBitArray s i -> ST s (STBitArray s i)
- fill :: Ix i => STBitArray s i -> Bool -> ST s ()
- or :: Ix i => STBitArray s i -> ST s Bool
- and :: Ix i => STBitArray s i -> ST s Bool
- isUniform :: Ix i => STBitArray s i -> ST s (Maybe Bool)
- fold :: Ix i => (Bool -> Bool -> Bool) -> STBitArray s i -> ST s (Maybe Bool)
- map :: Ix i => (Bool -> Bool) -> STBitArray s i -> ST s (STBitArray s i)
- zipWith :: Ix i => (Bool -> Bool -> Bool) -> STBitArray s i -> STBitArray s i -> ST s (STBitArray s i)
- unsafeReadArray :: Ix i => STBitArray s i -> i -> ST s Bool
- unsafeGetElems :: Ix i => STBitArray s i -> ST s [Bool]
- unsafeFreeze :: Ix i => STBitArray s i -> ST s (BitArray i)
- unsafeThaw :: Ix i => BitArray i -> ST s (STBitArray s i)
Documentation
data STBitArray s i Source
The type of mutable bit arrays.
MArray-like interface.
getBounds :: Ix i => STBitArray s i -> ST s (i, i) Source
Get the bounds of a bit array.
:: Ix i | |
=> (i, i) | bounds |
-> Bool | initial value |
-> ST s (STBitArray s i) |
Create a new array filled with an initial value.
:: Ix i | |
=> (i, i) | bounds |
-> ST s (STBitArray s i) |
Create a new array filled with a default initial value (False
).
:: Ix i | |
=> (i, i) | bounds |
-> [Bool] | elems |
-> ST s (STBitArray s i) |
Create a new array filled with values from a list.
writeArray :: Ix i => STBitArray s i -> i -> Bool -> ST s () Source
Write to an array at an index.
mapArray :: Ix i => (Bool -> Bool) -> STBitArray s i -> ST s (STBitArray s i) Source
Alias for map
.
:: (Ix i, Ix j) | |
=> (i, i) | new bounds |
-> (i -> j) | index transformation |
-> STBitArray s j | source array |
-> ST s (STBitArray s i) |
Create a new array by reading from another.
getAssocs :: Ix i => STBitArray s i -> ST s [(i, Bool)] Source
Get a list of all (index, element) pairs.
Conversion to/from immutable bit arrays.
freeze :: Ix i => STBitArray s i -> ST s (BitArray i) Source
Snapshot the array into an immutable form.
Construction.
copy :: Ix i => STBitArray s i -> ST s (STBitArray s i) Source
Copy an array.
Short-circuiting reductions.
or :: Ix i => STBitArray s i -> ST s Bool Source
Short-circuit bitwise reduction: True when any bit is True.
and :: Ix i => STBitArray s i -> ST s Bool Source
Short-circuit bitwise reduction: False when any bit is False.
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) -> STBitArray s i -> ST s (STBitArray s i) Source
Bitwise map. Implementation lifts from Bool
to Bits
and maps
large chunks at a time.
zipWith :: Ix i => (Bool -> Bool -> Bool) -> STBitArray s i -> STBitArray s i -> ST s (STBitArray s 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 => STBitArray s i -> i -> ST s Bool Source
Read from an array at an index without bounds checking. Unsafe.
unsafeGetElems :: Ix i => STBitArray s i -> ST s [Bool] Source
Get a list of all elements of an array without copying. Unsafe when the source array can be modified later.
unsafeFreeze :: Ix i => STBitArray s i -> ST s (BitArray i) Source
Snapshot the array into an immutable form. Unsafe when the source array can be modified later.
unsafeThaw :: Ix i => BitArray i -> ST s (STBitArray s i) Source
Convert an array from immutable form. Unsafe to modify the result unless the source array is never used later.