Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /smlnj-lib/branches/rt-transition/Util/ord-map-sig.sml
ViewVC logotype

Annotation of /smlnj-lib/branches/rt-transition/Util/ord-map-sig.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2274 - (view) (download)
Original Path: smlnj-lib/trunk/Util/ord-map-sig.sml

1 : monnier 2 (* ord-map-sig.sml
2 :     *
3 :     * COPYRIGHT (c) 1996 by AT&T Research. See COPYRIGHT file for details.
4 :     *
5 :     * Abstract signature of an applicative-style finite maps (dictionaries)
6 :     * structure over ordered monomorphic keys.
7 :     *)
8 :    
9 :     signature ORD_MAP =
10 :     sig
11 :    
12 :     structure Key : ORD_KEY
13 :    
14 :     type 'a map
15 :    
16 :     val empty : 'a map
17 :     (* The empty map *)
18 :    
19 : monnier 289 val isEmpty : 'a map -> bool
20 :     (* Return true if and only if the map is empty *)
21 :    
22 : monnier 411 val singleton : (Key.ord_key * 'a) -> 'a map
23 :     (* return the specified singleton map *)
24 :    
25 : monnier 29 val insert : 'a map * Key.ord_key * 'a -> 'a map
26 :     val insert' : ((Key.ord_key * 'a) * 'a map) -> 'a map
27 :     (* Insert an item. *)
28 : monnier 2
29 :     val find : 'a map * Key.ord_key -> 'a option
30 :     (* Look for an item, return NONE if the item doesn't exist *)
31 :    
32 : jhr 2274 val lookup : 'a map * Key.ord_key -> 'a
33 :     (* look for an item, raise the NotFound exception if it doesn't exist *)
34 :    
35 : monnier 411 val inDomain : ('a map * Key.ord_key) -> bool
36 :     (* return true, if the key is in the domain of the map *)
37 :    
38 : monnier 2 val remove : 'a map * Key.ord_key -> 'a map * 'a
39 :     (* Remove an item, returning new map and value removed.
40 :     * Raises LibBase.NotFound if not found.
41 :     *)
42 :    
43 : monnier 289 val first : 'a map -> 'a option
44 :     val firsti : 'a map -> (Key.ord_key * 'a) option
45 :     (* return the first item in the map (or NONE if it is empty) *)
46 :    
47 : monnier 2 val numItems : 'a map -> int
48 :     (* Return the number of items in the map *)
49 :    
50 :     val listItems : 'a map -> 'a list
51 :     val listItemsi : 'a map -> (Key.ord_key * 'a) list
52 : monnier 411 (* Return an ordered list of the items (and their keys) in the map. *)
53 : monnier 2
54 : monnier 411 val listKeys : 'a map -> Key.ord_key list
55 :     (* return an ordered list of the keys in the map. *)
56 :    
57 : monnier 2 val collate : ('a * 'a -> order) -> ('a map * 'a map) -> order
58 :     (* given an ordering on the map's range, return an ordering
59 :     * on the map.
60 :     *)
61 :    
62 :     val unionWith : ('a * 'a -> 'a) -> ('a map * 'a map) -> 'a map
63 :     val unionWithi : (Key.ord_key * 'a * 'a -> 'a) -> ('a map * 'a map) -> 'a map
64 :     (* return a map whose domain is the union of the domains of the two input
65 :     * maps, using the supplied function to define the map on elements that
66 :     * are in both domains.
67 :     *)
68 :    
69 :     val intersectWith : ('a * 'b -> 'c) -> ('a map * 'b map) -> 'c map
70 :     val intersectWithi : (Key.ord_key * 'a * 'b -> 'c) -> ('a map * 'b map) -> 'c map
71 :     (* return a map whose domain is the intersection of the domains of the
72 :     * two input maps, using the supplied function to define the range.
73 :     *)
74 :    
75 : jhr 1193 val mergeWith : ('a option * 'b option -> 'c option)
76 :     -> ('a map * 'b map) -> 'c map
77 :     val mergeWithi : (Key.ord_key * 'a option * 'b option -> 'c option)
78 :     -> ('a map * 'b map) -> 'c map
79 :     (* merge two maps using the given function to control the merge. For
80 :     * each key k in the union of the two maps domains, the function
81 :     * is applied to the image of the key under the map. If the function
82 :     * returns SOME y, then (k, y) is added to the resulting map.
83 :     *)
84 :    
85 : monnier 2 val app : ('a -> unit) -> 'a map -> unit
86 :     val appi : ((Key.ord_key * 'a) -> unit) -> 'a map -> unit
87 :     (* Apply a function to the entries of the map in map order. *)
88 :    
89 :     val map : ('a -> 'b) -> 'a map -> 'b map
90 :     val mapi : (Key.ord_key * 'a -> 'b) -> 'a map -> 'b map
91 :     (* Create a new map by applying a map function to the
92 :     * name/value pairs in the map.
93 :     *)
94 :    
95 :     val foldl : ('a * 'b -> 'b) -> 'b -> 'a map -> 'b
96 :     val foldli : (Key.ord_key * 'a * 'b -> 'b) -> 'b -> 'a map -> 'b
97 :     (* Apply a folding function to the entries of the map
98 :     * in increasing map order.
99 :     *)
100 :    
101 :     val foldr : ('a * 'b -> 'b) -> 'b -> 'a map -> 'b
102 :     val foldri : (Key.ord_key * 'a * 'b -> 'b) -> 'b -> 'a map -> 'b
103 :     (* Apply a folding function to the entries of the map
104 :     * in decreasing map order.
105 :     *)
106 :    
107 :     val filter : ('a -> bool) -> 'a map -> 'a map
108 :     val filteri : (Key.ord_key * 'a -> bool) -> 'a map -> 'a map
109 :     (* Filter out those elements of the map that do not satisfy the
110 :     * predicate. The filtering is done in increasing map order.
111 :     *)
112 :    
113 :     val mapPartial : ('a -> 'b option) -> 'a map -> 'b map
114 :     val mapPartiali : (Key.ord_key * 'a -> 'b option) -> 'a map -> 'b map
115 :     (* map a partial function over the elements of a map in increasing
116 :     * map order.
117 :     *)
118 :    
119 :     end (* ORD_MAP *)

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0