| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Consensus.Util.Bitmap
Description
A compact bitmap representation using serialisation-ready ByteStrings.
Adapted from Cardano.Leios.BitMapPV in the leios-wfa-ls-demo package.
NOTE: this module is meant to be imported qualified.
Synopsis
- data Bitmap a
- fromIndices ∷ Integral a ⇒ a → [a] → Bitmap a
- toIndices ∷ Integral a ⇒ Bitmap a → [a]
- logicalUpperBound ∷ Bitmap a → a
- rawSerialise ∷ Bitmap a → ByteString
- rawDeserialise ∷ Integral a ⇒ a → ByteString → Maybe (Bitmap a)
Documentation
A compact bitmap representation over an index type.
NOTE: the logical upper bound is stored explicitly so serialisation round-trips exactly.
fromIndices ∷ Integral a ⇒ a → [a] → Bitmap a Source #
Construct a Bitmap from a list of indexes that should be set (flipped to
1) and a maximum index (inclusive logical upper bound).
toIndices ∷ Integral a ⇒ Bitmap a → [a] Source #
Retrieve all indexes that are set (flipped to 1) in the bitmap, in ascending order.
logicalUpperBound ∷ Bitmap a → a Source #
Get the logical upper bound of a bitmap
rawSerialise ∷ Bitmap a → ByteString Source #
Raw serialisation of the bitmap (just the underlying bytes, without the logical upper bound).
rawDeserialise ∷ Integral a ⇒ a → ByteString → Maybe (Bitmap a) Source #
Raw deserialisation of a bitmap from a logical upper bound and a ByteString
Returns Nothing if the byte string length does not match the expected size
for the given upper bound.