ouroboros-consensus
Safe HaskellNone
LanguageHaskell2010

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

Documentation

data Bitmap a Source #

A compact bitmap representation over an index type.

NOTE: the logical upper bound is stored explicitly so serialisation round-trips exactly.

Instances

Instances details
(Integral a, FromCBOR a) ⇒ FromCBOR (Bitmap a) Source # 
Instance details

Defined in Ouroboros.Consensus.Util.Bitmap

Methods

fromCBORDecoder s (Bitmap a) Source #

labelProxy (Bitmap a) → Text Source #

ToCBOR a ⇒ ToCBOR (Bitmap a) Source # 
Instance details

Defined in Ouroboros.Consensus.Util.Bitmap

Methods

toCBORBitmap a → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (Bitmap a) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Bitmap a] → Size Source #

Show a ⇒ Show (Bitmap a) Source # 
Instance details

Defined in Ouroboros.Consensus.Util.Bitmap

Methods

showsPrecIntBitmap a → ShowS #

showBitmap a → String #

showList ∷ [Bitmap a] → ShowS #

Eq a ⇒ Eq (Bitmap a) Source # 
Instance details

Defined in Ouroboros.Consensus.Util.Bitmap

Methods

(==)Bitmap a → Bitmap a → Bool #

(/=)Bitmap a → Bitmap a → Bool #

fromIndicesIntegral 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).

toIndicesIntegral a ⇒ Bitmap a → [a] Source #

Retrieve all indexes that are set (flipped to 1) in the bitmap, in ascending order.

logicalUpperBoundBitmap a → a Source #

Get the logical upper bound of a bitmap

rawSerialiseBitmap a → ByteString Source #

Raw serialisation of the bitmap (just the underlying bytes, without the logical upper bound).

rawDeserialiseIntegral a ⇒ a → ByteStringMaybe (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.