bitwise-0.1.1.1: fast multi-dimensional unboxed bit packed Bool arrays

Copyright(c) Claude Heiland-Allen 2012
LicenseBSD3
Maintainerclaude@mathr.co.uk
Stabilityunstable
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Data.Array.BitArray

Contents

Description

Immutable unboxed packed bit arrays using bitwise operations to manipulate large chunks at a time much more quickly than individually unpacking and repacking bits would allow.

Synopsis

Documentation

data BitArray i Source

The type of immutable bit arrays.

IArray-like interface.

bounds :: Ix i => BitArray i -> (i, i) Source

The bounds of an array.

array Source

Arguments

:: Ix i 
=> (i, i)

bounds

-> [(i, Bool)]

assocs

-> BitArray i 

Create an array from a list of (index, element) pairs.

listArray Source

Arguments

:: Ix i 
=> (i, i)

bounds

-> [Bool]

elems

-> BitArray i 

Create an array from a list of elements.

accumArray Source

Arguments

:: Ix i 
=> (Bool -> a -> Bool)

operation

-> Bool

default

-> (i, i)

bounds

-> [(i, a)]

assocs

-> BitArray i 

Create an array by accumulating a list of (index, operand) pairs from a default seed with an operation.

(!) :: Ix i => BitArray i -> i -> Bool Source

Bit array indexing.

indices :: Ix i => BitArray i -> [i] Source

A list of all the valid indices for this array.

elems :: Ix i => BitArray i -> [Bool] Source

A list of the elements in this array.

assocs :: Ix i => BitArray i -> [(i, Bool)] Source

A list of the (index, element) pairs in this array.

(//) Source

Arguments

:: Ix i 
=> BitArray i 
-> [(i, Bool)]

new assocs

-> BitArray i 

A new array with updated values at the supplied indices.

accum Source

Arguments

:: Ix i 
=> (Bool -> a -> Bool)

operation

-> BitArray i

source

-> [(i, a)]

assocs

-> BitArray i 

Accumulate with an operation and a list of (index, operand).

amap :: Ix i => (Bool -> Bool) -> BitArray i -> BitArray i Source

Alias for map.

ixmap Source

Arguments

:: (Ix i, Ix j) 
=> (i, i)

new bounds

-> (i -> j)

index transformation

-> BitArray j

source array

-> BitArray i 

Create a new array by mapping indices into a source array..

Constant arrays.

fill Source

Arguments

:: Ix i 
=> (i, i)

bounds

-> Bool 
-> BitArray i 

A uniform array of bits.

false Source

Arguments

:: Ix i 
=> (i, i)

bounds

-> BitArray i 

A uniform array of False.

true Source

Arguments

:: Ix i 
=> (i, i)

bounds

-> BitArray i 

A uniform array of True.

Short-circuiting reductions.

or :: Ix i => BitArray i -> Bool Source

Short-circuit bitwise reduction: True if any bit is True.

and :: Ix i => BitArray i -> Bool Source

Short-circuit bitwise reduction: False if any bit is False.

isUniform :: Ix i => BitArray i -> Maybe Bool Source

Short-circuit bitwise reduction: Nothing if any bits differ.

elemIndex :: Bool -> BitArray Int -> 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.

fold :: Ix i => (Bool -> Bool -> Bool) -> BitArray i -> Maybe Bool Source

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) -> BitArray i -> BitArray i Source

Bitwise map. Implementation lifts from Bool to Bits and maps large chunks at a time.

zipWith :: Ix i => (Bool -> Bool -> Bool) -> BitArray i -> BitArray i -> BitArray 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.

popCount :: Ix i => BitArray i -> Int Source

Count set bits.

Bounds-checked indexing.

(!?) :: Ix i => BitArray i -> i -> Maybe Bool Source

Bounds checking combined with array indexing.

Unsafe.

(!!!) :: Ix i => BitArray i -> i -> Bool Source

Bit array indexing without bounds checking. Unsafe.