|
|
|
|
| Map provides mapping between two arbitrary types. | |
type <'a, 'b>t; | |
| Type of maps from 'a to 'b. | |
<'a, 'b>t create(*(int ('a, 'a)) cmp); | |
| Create new hash, empty table. cmp is comparison function. | |
<'a, 'b>t add(<'a, 'b>t m, 'a k, 'b v); | |
| Add element v with key k to m. If there is already element with the same key it is removed. | |
'b find(<'a, 'b>t m, 'a k); | |
| Lookup element with key k in m. Raise Not_found if element is not in map. Otherwise return it. | |
<'a, 'b>t remove(<'a, 'b>t m, 'a k); | |
| Remove one element with key k from m. Raise Not_found if element is not in map. | |
bool mem(<'a, 'b>t m, 'a k); | |
| Return true iff element with key k is in m. | |
int length(<'a, 'b>t m); | |
| Return number of elements stored in m. | |
<'a>list keys(<'a, 'b>t m); | |
| Return list of keys of elements stored in m. Keys are returned in ascending order. | |
<'b>list values(<'a, 'b>t m); | |
| Return list of values of elements stored in m. Values are returned in ascending order of respective keys. | |
void iter(<'a, 'b>t m, *(void ('a, 'b)) f); | |
| Execute f on each element of m, passing it its key and value. | |
'c fold(<'a, 'b>t m, 'c start, *('c ('c, 'a, 'b)) f); | |
| Execute f on each element of m, passing it its key and value. | |
<'a, 'b>t of_assoc_list(*(int ('a, 'a)) cmp, <*('a, 'b)>list assoc); | |
| Create new map and add each (key, value) pair from assoc. Return created map. | |