Revision c6484f0b Ganeti/HTools/Container.hs
b/Ganeti/HTools/Container.hs | ||
---|---|---|
71 | 71 |
find :: Key -> Container a -> a |
72 | 72 |
find k c = c IntMap.! k |
73 | 73 |
|
74 |
-- | Locate a keyin the map returning a default value if not existing. |
|
75 |
findWithDefault :: a -> Key -> Container a -> a |
|
76 |
findWithDefault = IntMap.findWithDefault |
|
77 |
|
|
78 | 74 |
-- | Add or update one element to the map. |
79 | 75 |
add :: Key -> a -> Container a -> Container a |
80 | 76 |
add k v c = IntMap.insert k v c |
... | ... | |
95 | 91 |
fromAssocList :: [(Key, a)] -> Container a |
96 | 92 |
fromAssocList = IntMap.fromList |
97 | 93 |
|
98 |
-- | Create a map from an association list with a combining function. |
|
99 |
fromListWith :: (a -> a -> a) -> [(Key, a)] -> Container a |
|
100 |
fromListWith = IntMap.fromListWith |
|
101 |
|
|
102 |
-- | Fold over the values of the map. |
|
103 |
fold :: (a -> b -> b) -> b -> Container a -> b |
|
104 |
fold = IntMap.fold |
|
105 |
|
|
106 | 94 |
-- | Add or update two elements of the map. |
107 | 95 |
addTwo :: Key -> a -> Key -> a -> Container a -> Container a |
108 | 96 |
addTwo k1 v1 k2 v2 c = add k1 v1 $ add k2 v2 c |
Also available in: Unified diff