ganeti

Safe HaskellSafe-Infered

Ganeti.Objects.BitArray

Description

Space efficient bit arrays

The module is meant to be imported qualified (as it is common with collection libraries).

Synopsis

Documentation

data BitArray Source

A fixed-size, space-efficient array of bits.

Constructors

BitArray 

Fields

size :: !Int
 
_bitArrayBits :: !IntSet
 

Instances

Eq BitArray 
Ord BitArray 
Show BitArray 
Arbitrary BitArray 
JSON 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/

count0 :: BitArray -> IntSource

Computes the number of zeroes in the array.

count1 :: BitArray -> IntSource

Computes the number of ones in the array.

(!) :: 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.

(-|-) :: BitArray -> BitArray -> BitArraySource

A union of two bit arrays. The length of the result is the maximum length of the two.

subset :: BitArray -> BitArray -> BoolSource

Checks if the first array is a subset of the other.

toList :: BitArray -> [Bool]Source

Converts a bit array into a list of booleans.

fromList :: [Bool] -> BitArraySource

Converts a list of booleans to a BitArray.