ganeti-htoolsSource codeContentsIndex
Ganeti.HTools.PeerMap
Contents
Type definitions
Initialization functions
Basic operations
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 Key = Ndx
type Elem = Int
type PeerMap = [(Key, Elem)]
empty :: PeerMap
pmCompare :: (Key, Elem) -> (Key, Elem) -> Ordering
addWith :: (Elem -> Elem -> Elem) -> Key -> Elem -> PeerMap -> PeerMap
accumArray :: (Elem -> Elem -> Elem) -> [(Key, Elem)] -> PeerMap
find :: Key -> PeerMap -> Elem
add :: Key -> Elem -> PeerMap -> PeerMap
remove :: Key -> PeerMap -> PeerMap
maxElem :: PeerMap -> Elem
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
Our reverse-compare function.
addWith :: (Elem -> Elem -> Elem) -> Key -> Elem -> PeerMap -> PeerMapSource
Add or update (via a custom function) an element.
accumArraySource
:: Elem -> Elem -> Elemfunction used to merge the elements
-> [(Key, Elem)]source data
-> PeerMapresults
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

Produced by Haddock version 2.6.0