ganeti

Safe HaskellSafe-Infered

Ganeti.HTools.PeerMap

Contents

Description

Module abstracting the peer map implementation.

This is abstracted separately since the speed of peermap updates can be a significant part of the total runtime, and as such changing the implementation should be easy in case it's needed.

Synopsis

Type definitions

type Key = NdxSource

Our key type.

type Elem = IntSource

Our element type.

type PeerMap = [(Key, Elem)]Source

The definition of a peer map.

Initialization functions

empty :: PeerMapSource

Create a new empty map.

pmCompare :: (Key, Elem) -> (Key, Elem) -> OrderingSource

accumArraySource

Arguments

:: (Elem -> Elem -> Elem)

function used to merge the elements

-> [(Key, Elem)]

source data

-> PeerMap

results

Create a PeerMap from an association list, with possible duplicates.

Basic operations

find :: Key -> PeerMap -> ElemSource

Returns either the value for a key or zero if not found.

add :: Key -> Elem -> PeerMap -> PeerMapSource

Add an element to a peermap, overwriting the previous value.

remove :: Key -> PeerMap -> PeerMapSource

Remove an element from a peermap.

maxElem :: PeerMap -> ElemSource

Find the maximum element.

Since this is a sorted list, we just get the value at the head of the list, or zero for a null list