ganeti

Safe HaskellNone

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 = Ndx Source #

Our key type.

type Elem = Int Source #

Our element type.

type PeerMap = [(Key, Elem)] Source #

The definition of a peer map.

Initialization functions

empty :: PeerMap Source #

Create a new empty map.

accumArray Source #

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

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

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

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

remove :: Key -> PeerMap -> PeerMap Source #

Remove an element from a peermap.

maxElem :: PeerMap -> Elem Source #

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

Sum of all peers.