ganeti
Safe HaskellNone

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

Instances

Instances details
Eq BitArray # 
Instance details

Defined in Ganeti.Objects.BitArray

Methods

(==) :: BitArray -> BitArray -> Bool

(/=) :: BitArray -> BitArray -> Bool

Ord BitArray # 
Instance details

Defined in Ganeti.Objects.BitArray

Methods

compare :: BitArray -> BitArray -> Ordering

(<) :: BitArray -> BitArray -> Bool

(<=) :: BitArray -> BitArray -> Bool

(>) :: BitArray -> BitArray -> Bool

(>=) :: BitArray -> BitArray -> Bool

max :: BitArray -> BitArray -> BitArray

min :: BitArray -> BitArray -> BitArray

Show BitArray # 
Instance details

Defined in Ganeti.Objects.BitArray

Methods

showsPrec :: Int -> BitArray -> ShowS

show :: BitArray -> String

showList :: [BitArray] -> ShowS

JSON BitArray # 
Instance details

Defined in Ganeti.Objects.BitArray

Methods

readJSON :: JSValue -> Result BitArray

showJSON :: BitArray -> JSValue

readJSONs :: JSValue -> Result [BitArray]

showJSONs :: [BitArray] -> JSValue

Arbitrary BitArray 
Instance details

Defined in Test.Ganeti.Objects.BitArray

foldr :: (Bool -> Int -> a -> a) -> a -> BitArray -> a Source #

Right fold over the set, including indexes of each value.

asString :: Char -> Char -> BitArray -> String Source #

Converts a bit array into a string, given characters for 0 and 1/

count0 :: BitArray -> Int Source #

Computes the number of zeroes in the array.

count1 :: BitArray -> Int Source #

Computes the number of ones in the array.

(!) :: BitArray -> Int -> Bool infixl 9 Source #

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 BitArray Source #

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 -> BitArray infixl 7 Source #

An intersection of two bit arrays. The length of the result is the minimum length of the two.

(-|-) :: BitArray -> BitArray -> BitArray infixl 5 Source #

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

subset :: BitArray -> BitArray -> Bool Source #

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] -> BitArray Source #

Converts a list of booleans to a BitArray.