ganeti-3.1: Cluster-based virtualization management software
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ganeti.HTools.PeerMap

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

Documentation

type PeerMap = [(Key, Elem)] #

The definition of a peer map.

type Key = Ndx #

Our key type.

type Elem = Int #

Our element type.

empty :: PeerMap #

Create a new empty map.

accumArray #

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.

find :: Key -> PeerMap -> Elem #

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

add :: Key -> Elem -> PeerMap -> PeerMap #

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

remove :: Key -> PeerMap -> PeerMap #

Remove an element from a peermap.

maxElem :: PeerMap -> Elem #

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

sumElems :: PeerMap -> Elem #

Sum of all peers.