A finite map is an efficient purely functional data structure
to store a mapping from keys to values.
In order to store the mapping efficiently, an irreflexive(!) order predicate
has to be given, i.e., the order predicate le should not satisfy
(le x x) for some key x.
Example: To store a mapping from Int -> String, the finite map needs
a Boolean predicate like (<).
This version was ported from a corresponding Haskell library
Author: Frank Huch, Bernd Brassel
Version: May 2005
| Exported names: |
Datatypes:
FM
Functions:
addListToFM
| addListToFM_C
| addToFM
| addToFM_C
| delFromFM
| delListFromFM
| elemFM
| eltsFM
| emptyFM
| eqFM
| filterFM
| fmSortBy
| fmToList
| fmToListPreOrder
| foldFM
| intersectFM
| intersectFM_C
| isEmptyFM
| keyOrder
| keysFM
| listToFM
| lookupFM
| lookupWithDefaultFM
| mapFM
| maxFM
| minFM
| minusFM
| plusFM
| plusFM_C
| sizeFM
| splitFM
| unitFM
| updFM
| Summary of exported functions: |
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
| Imported modules: |
| Exported datatypes: |
Constructors:
| Exported functions: |
:: (a -> a -> Bool) -> FM a b
The empty finite map.
Example call: (emptyFM le)
le
an irreflexive order predicate on the keys.
:: (a -> a -> Bool) -> a -> b -> FM a b
Construct a finite map with only a single element.
Example call: (unitFM le key elt)
le
an irreflexive order predicate on the keys.
key
key of
elt
the single element to form
:: (a -> a -> Bool) -> [(a,b)] -> FM a b
Builts a finite map from given list of tuples (key,element). For multiple occurences of key, the last corresponding element of the list is taken.
Example call: (listToFM le)
le
an irreflexive order predicate on the keys.
:: FM a b -> a -> b -> FM a b
Throws away any previous binding and stores the new one given.
:: FM a b -> [(a,b)] -> FM a b
Throws away any previous bindings and stores the new ones given. The items are added starting with the first one in the list
:: (a -> a -> a) -> FM b a -> b -> a -> FM b a
Instead of throwing away the old binding, addToFM_C combines the new element with the old one.
Example call: (addToFM_C combiner fm key elt)
combiner
a function combining to elements
fm
a finite map
key
the key of the elements to be combined
elt
the new element
:: (a -> a -> a) -> FM b a -> [(b,a)] -> FM b a
Combine with a list of tuples (key,element), cf. addToFM_C
:: FM a b -> a -> FM a b
Deletes key from finite map. Deletion doesn't complain if you try to delete something which isn't there
:: FM a b -> [a] -> FM a b
Deletes a list of keys from finite map. Deletion doesn't complain if you try to delete something which isn't there
:: FM a b -> a -> (b -> b) -> FM a b
Applies a function to element bound to given key.
:: FM a b -> a -> Maybe (FM a b,(a,b))
Combines delFrom and lookup.
:: FM a b -> FM a b -> FM a b
Efficiently add key/element mappings of two maps into a single one. Bindings in right argument shadow those in the left
:: (a -> a -> a) -> FM b a -> FM b a -> FM b a
Efficiently combine key/element mappings of two maps into a single one, cf. addToFM_C
:: FM a b -> FM a b -> FM a b
(minusFM a1 a2) deletes from a1 any bindings which are bound in a2
:: FM a b -> FM a b -> FM a b
Filters only those keys that are bound in both of the given maps. The elements will be taken from the second map.
:: (a -> a -> b) -> FM c a -> FM c a -> FM c b
Filters only those keys that are bound in both of the given maps and combines the elements as in addToFM_C.
:: (a -> b -> c -> c) -> c -> FM a b -> c
Folds finite map by given function.
:: (a -> b -> c) -> FM a b -> FM a c
Applies a given function on every element in the map.
:: (a -> b -> Bool) -> FM a b -> FM a b
Yields a new finite map with only those key/element pairs matching the given predicate.
:: FM a b -> Int
How many elements does given map contain?
:: FM a b -> FM a b -> Bool
Do two given maps contain the same key/element pairs?
:: FM a b -> Bool
Is the given finite map empty?
:: a -> FM a b -> Bool
Does given map contain given key?
:: FM a b -> a -> Maybe b
Retrieves element bound to given key
:: FM a b -> b -> a -> b
Retrieves element bound to given key. If the element is not contained in map, return default value.
:: FM a b -> a -> a -> Bool
Retrieves the ordering on which the given finite map is built.
:: FM a b -> Maybe (a,b)
Retrieves the smallest key/element pair in the finite map according to the basic key ordering.
:: FM a b -> Maybe (a,b)
Retrieves the greatest key/element pair in the finite map according to the basic key ordering.
:: FM a b -> [(a,b)]
Builds a list of key/element pairs. The list is ordered by the initially given irreflexive order predicate on keys.
:: FM a b -> [a]
Retrieves a list of keys contained in finite map. The list is ordered by the initially given irreflexive order predicate on keys.
:: FM a b -> [b]
Retrieves a list of elements contained in finite map. The list is ordered by the initially given irreflexive order predicate on keys.
:: FM a b -> [(a,b)]
Retrieves list of key/element pairs in preorder of the internal tree. Useful for lists that will be retransformed into a tree or to match any elements regardless of basic order.
:: (a -> a -> Bool) -> [a] -> [a]
Sorts a given list by inserting and retrieving from finite map. Duplicates are deleted.