Portability | portable |
---|---|
Stability | experimental |
Maintainer | Stefan Schmidt (stefanschmidt@web.de) |
Version : 0.1
A map of key-value-pairs. The values are hold in a list, so adding the same key-value-pair twice to the map, will result in storing the value twice. Even the sequence of adding the values will be saved.
The name AccuMap is from accumulation map. You can use this map to easily storing all you key-value-pairs. After that you can all values-lists by key. Unlike the MultiMap, you don't lose the information of identical values and their order of adding.
Most functions are inspired by the Data.Map type.
- data AccuMap k a
- empty :: Ord k => AccuMap k a
- null :: Ord k => AccuMap k a -> Bool
- insert :: Ord k => k -> a -> AccuMap k a -> AccuMap k a
- insertList :: Ord k => k -> [a] -> AccuMap k a -> AccuMap k a
- lookup :: Ord k => k -> AccuMap k a -> [a]
- member :: (Ord k, Eq a) => k -> AccuMap k a -> Bool
- deleteKey :: Ord k => k -> AccuMap k a -> AccuMap k a
- union :: Ord k => AccuMap k a -> AccuMap k a -> AccuMap k a
- fromList :: Ord k => [(k, [a])] -> AccuMap k a
- fromTupleList :: Ord k => [(k, a)] -> AccuMap k a
- toList :: Ord k => AccuMap k a -> [(k, [a])]
Documentation
the AccuMap datatype
insert :: Ord k => k -> a -> AccuMap k a -> AccuMap k aSource
Insert a key-value-pair to the AccuMap.
insertList :: Ord k => k -> [a] -> AccuMap k a -> AccuMap k aSource
Insert a key and a list of values to the AccuMap. Faster than adding all pair one by one.
lookup :: Ord k => k -> AccuMap k a -> [a]Source
Get the list of values for one key. If the key doesn't exists, an empty list is returned.
deleteKey :: Ord k => k -> AccuMap k a -> AccuMap k aSource
Deletes a key and all its values from the AccuMap.
union :: Ord k => AccuMap k a -> AccuMap k a -> AccuMap k aSource
Combines two AccuMaps, the ordering of the two maps is significant for the order of the values-elements.
fromTupleList :: Ord k => [(k, a)] -> AccuMap k aSource
Creates an AccuMap from a tuple list.