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

SCM Repository

[smlnj] Diff of /smlnj-lib/branches/rt-transition/Doc/ML-Doc/Util/ord-map.mldoc
ViewVC logotype

Diff of /smlnj-lib/branches/rt-transition/Doc/ML-Doc/Util/ord-map.mldoc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4069, Tue Jun 9 20:52:48 2015 UTC revision 4070, Thu Jun 11 12:33:25 2015 UTC
# Line 27  Line 27 
27    <SIGBODY SIGID="ORD_MAP" FILE=ORD-MAP>    <SIGBODY SIGID="ORD_MAP" FILE=ORD-MAP>
28      <SPEC>      <SPEC>
29        <SUBSTRUCT>Key<ID>ORD_KEY</SUBSTRUCT>        <SUBSTRUCT>Key<ID>ORD_KEY</SUBSTRUCT>
30        </SPEC>
31      <SPEC>      <SPEC>
32        <TYPE><TYPARAM>'a<ID>map        <TYPE><TYPARAM>'a<ID>map
33        </SPEC>
34      <SPEC>      <SPEC>
35        <VAL>empty<TY>'a map        <VAL>empty<TY>'a map
36          <COMMENT>          <COMMENT>
37            <PP>            <PP>
38            The empty map.            The empty map.
39          </COMMENT>          </COMMENT>
40        </SPEC>
41      <SPEC>      <SPEC>
42        <VAL>singleton<TY>(Key.ord_key * 'a) -> 'a map        <VAL>singleton<TY>(Key.ord_key * 'a) -> 'a map
43          <COMMENT>          <COMMENT>
# Line 44  Line 47 
47            returns the singleton map that maps the key <ARG/k/ to the            returns the singleton map that maps the key <ARG/k/ to the
48            value <ARG/a/.            value <ARG/a/.
49          </COMMENT>          </COMMENT>
50        </SPEC>
51      <SPEC>      <SPEC>
52        <VAL>insert<TY>('a map * Key.ord_key * 'a) -> 'a map        <VAL>insert<TY>('a map * Key.ord_key * 'a) -> 'a map
53        <VAL>insert'<TY>((Key.ord_key * 'a) * 'a map) -> 'a map        <VAL>insert'<TY>((Key.ord_key * 'a) * 'a map) -> 'a map
# Line 55  Line 59 
59            </PROTOTY>            </PROTOTY>
60            creates a new map by inserting the key-value pair into <ARG/ma/.            creates a new map by inserting the key-value pair into <ARG/ma/.
61          </COMMENT>          </COMMENT>
62        </SPEC>
63      <SPEC>      <SPEC>
64        <VAL>inDomain<TY>('a map * Key.ord_key) -> bool        <VAL>inDomain<TY>('a map * Key.ord_key) -> bool
65          <COMMENT>          <COMMENT>
# Line 63  Line 68 
68            </PROTOTY>            </PROTOTY>
69            returns <CD/true/ if the key <ARG/k/ is in the domain of <ARG/ma/,            returns <CD/true/ if the key <ARG/k/ is in the domain of <ARG/ma/,
70            otherwise it returns <CD/false/.            otherwise it returns <CD/false/.
71        </SPEC>
72      <SPEC>      <SPEC>
73        <VAL>find<TY>('a map * Key.ord_key) -> 'a option        <VAL>find<TY>('a map * Key.ord_key) -> 'a option
74          <COMMENT>          <COMMENT>
# Line 72  Line 78 
78            looks for an item in <ARG/ma/ keyed by <ARG/k/. It returns the            looks for an item in <ARG/ma/ keyed by <ARG/k/. It returns the
79            item if it finds it; otherwise, returns            item if it finds it; otherwise, returns
80            <CONREF STRID="Option" DOCUMENT=SML-BASIS-DOC/NONE/.            <CONREF STRID="Option" DOCUMENT=SML-BASIS-DOC/NONE/.
81        </SPEC>
82      <SPEC>      <SPEC>
83        <VAL>remove<TY>('a map * Key.ord_key) -> ('a map * 'a)        <VAL>remove<TY>('a map * Key.ord_key) -> ('a map * 'a)
84        <RAISES><EXNREF STRID="LibBase"/NotFound/        <RAISES><EXNREF STRID="LibBase"/NotFound/
# Line 82  Line 89 
89            removes an item from <ARG/ma/ corresponding to the key <ARG/k/.            removes an item from <ARG/ma/ corresponding to the key <ARG/k/.
90            If found, the resulting map and item are returned. Raises            If found, the resulting map and item are returned. Raises
91            <EXNREF STRID="LibBase"/NotFound/ if no such item exists.            <EXNREF STRID="LibBase"/NotFound/ if no such item exists.
92        </SPEC>
93      <SPEC>      <SPEC>
94        <VAL>first<TY>'a map -> 'a option        <VAL>first<TY>'a map -> 'a option
95        <VAL>firsti<TY>'a map -> (Key.ord_key * 'a option)        <VAL>firsti<TY>'a map -> (Key.ord_key * 'a option)
# Line 99  Line 107 
107            Both of these functions return            Both of these functions return
108            <CONREF STRID="Option" DOCUMENT=SML-BASIS-DOC/NONE/ when called            <CONREF STRID="Option" DOCUMENT=SML-BASIS-DOC/NONE/ when called
109            on the empty map.            on the empty map.
110        </SPEC>
111      <SPEC>      <SPEC>
112        <VAL>numItems<TY>'a map -> int        <VAL>numItems<TY>'a map -> int
113          <COMMENT>          <COMMENT>
# Line 106  Line 115 
115            numItems <ARG/ma/            numItems <ARG/ma/
116            </PROTOTY>            </PROTOTY>
117            returns the number of items in the map.            returns the number of items in the map.
118        </SPEC>
119      <SPEC>      <SPEC>
120        <VAL>listItems<TY>'a map -> 'a list        <VAL>listItems<TY>'a map -> 'a list
121        <VAL>listItemsi<TY>'a map -> (Key.ord_key * 'a) list        <VAL>listItemsi<TY>'a map -> (Key.ord_key * 'a) list
# Line 117  Line 127 
127            </PROTOTY>            </PROTOTY>
128            return a list of the items in the map, ordered by increasing            return a list of the items in the map, ordered by increasing
129            key. The second form also returns the key.            key. The second form also returns the key.
130        </SPEC>
131      <SPEC>      <SPEC>
132        <VAL>collate<TY>(('a * 'a) -> order) -> ('a map * 'a map) -> order        <VAL>collate<TY>(('a * 'a) -> order) -> ('a map * 'a map) -> order
133          <COMMENT>          <COMMENT>
# Line 125  Line 136 
136            </PROTOTY>            </PROTOTY>
137            returns an ordering on maps, given an ordering on the maps'            returns an ordering on maps, given an ordering on the maps'
138            range.            range.
139        </SPEC>
140      <SPEC>      <SPEC>
141        <VAL>unionWith<TY>(('a * 'a) -> 'a) -> ('a map * 'a map) -> 'a map        <VAL>unionWith<TY>(('a * 'a) -> 'a) -> ('a map * 'a map) -> 'a map
142        <VAL>unionWithi<TY>((Key.ord_key * 'a * 'a) -> 'a) -> ('a map * 'a map) -> 'a map        <VAL>unionWithi<TY>((Key.ord_key * 'a * 'a) -> 'a) -> ('a map * 'a map) -> 'a map
# Line 138  Line 150 
150            The first argument is used to define the map on elements that            The first argument is used to define the map on elements that
151            are in the domain of both maps. In the second form, the function            are in the domain of both maps. In the second form, the function
152            takes the shared key as well as the two range values.            takes the shared key as well as the two range values.
153        </SPEC>
154      <SPEC>      <SPEC>
155        <VAL>intersectWith<TY>(('a * 'b) -> 'c) -> ('a map * 'b map) -> 'c map        <VAL>intersectWith<TY>(('a * 'b) -> 'c) -> ('a map * 'b map) -> 'c map
156        <VAL>intersectWithi<TY>((Key.ord_key * 'a * 'b) -> 'c) -> ('a map * 'b map) -> 'c map        <VAL>intersectWithi<TY>((Key.ord_key * 'a * 'b) -> 'c) -> ('a map * 'b map) -> 'c map
# Line 152  Line 165 
165            used to define the range. Specifically, if <CD/(k,u)/ is in            used to define the range. Specifically, if <CD/(k,u)/ is in
166            <ARG/ma/ and <CD/(k,v)/ is in <ARG/ma2/, the new map contains            <ARG/ma/ and <CD/(k,v)/ is in <ARG/ma2/, the new map contains
167            <CD/(k,f(u,v))/ (or <CD/(k,f(k,u,v))/, in the second case).            <CD/(k,f(u,v))/ (or <CD/(k,f(k,u,v))/, in the second case).
168        </SPEC>
169      <SPEC>      <SPEC>
170        <VAL>app<TY>('a -> unit) -> 'a map -> unit        <VAL>app<TY>('a -> unit) -> 'a map -> unit
171        <VAL>appi<TY>((Key.ord_key * 'a) -> unit) -> 'a map -> unit        <VAL>appi<TY>((Key.ord_key * 'a) -> unit) -> 'a map -> unit
# Line 168  Line 182 
182            List.app <ARG/f/ (listItems <ARG/ma/)            List.app <ARG/f/ (listItems <ARG/ma/)
183            List.app <ARG/f/ (listItemsi <ARG/ma/)            List.app <ARG/f/ (listItemsi <ARG/ma/)
184            </CODE>            </CODE>
185        </SPEC>
186      <SPEC>      <SPEC>
187        <VAL>map<TY>('a -> 'b) -> 'a map -> 'b map        <VAL>map<TY>('a -> 'b) -> 'a map -> 'b map
188        <VAL>mapi<TY>((Key.ord_key * 'a) -> 'b) -> 'a map -> 'b map        <VAL>mapi<TY>((Key.ord_key * 'a) -> 'b) -> 'a map -> 'b map
# Line 184  Line 199 
199            List.foldl (fn((k,v),m) => insert(m,k,f v)) empty (listItemsi ma)            List.foldl (fn((k,v),m) => insert(m,k,f v)) empty (listItemsi ma)
200            List.foldl (fn((k,v),m) => insert(m,k,f(k,v))) empty (listItemsi ma)            List.foldl (fn((k,v),m) => insert(m,k,f(k,v))) empty (listItemsi ma)
201            </CODE>            </CODE>
202        </SPEC>
203      <SPEC>      <SPEC>
204        <VAL>foldl<TY>(('a * 'b) -> 'b) -> 'b -> 'a map -> 'b        <VAL>foldl<TY>(('a * 'b) -> 'b) -> 'b -> 'a map -> 'b
205        <VAL>foldli<TY>((Key.ord_key * 'a * 'b) -> 'b) -> 'b -> 'a map -> 'b        <VAL>foldli<TY>((Key.ord_key * 'a * 'b) -> 'b) -> 'b -> 'a map -> 'b
# Line 199  Line 215 
215            List.foldl f a (listItems ma)            List.foldl f a (listItems ma)
216            List.foldl (fn((k,v),b) => f(k,v,b)) a (listItemsi ma)            List.foldl (fn((k,v),b) => f(k,v,b)) a (listItemsi ma)
217            </CODE>            </CODE>
218        </SPEC>
219      <SPEC>      <SPEC>
220        <VAL>foldr<TY>(('a * 'b) -> 'b) -> 'b -> 'a map -> 'b        <VAL>foldr<TY>(('a * 'b) -> 'b) -> 'b -> 'a map -> 'b
221        <VAL>foldri<TY>((Key.ord_key * 'a * 'b) -> 'b) -> 'b -> 'a map -> 'b        <VAL>foldri<TY>((Key.ord_key * 'a * 'b) -> 'b) -> 'b -> 'a map -> 'b
# Line 214  Line 231 
231            List.foldr f a (listItems ma)            List.foldr f a (listItems ma)
232            List.foldr (fn((k,v),b) => f(k,v,b)) a (listItemsi ma)            List.foldr (fn((k,v),b) => f(k,v,b)) a (listItemsi ma)
233            </CODE>            </CODE>
234        </SPEC>
235      <SPEC>      <SPEC>
236        <VAL>filter<TY>('a -> bool) -> 'a map -> 'a map        <VAL>filter<TY>('a -> bool) -> 'a map -> 'a map
237        <VAL>filteri<TY>((Key.ord_key * 'a) -> bool) -> 'a map -> 'a map        <VAL>filteri<TY>((Key.ord_key * 'a) -> bool) -> 'a map -> 'a map
# Line 230  Line 248 
248            List.foldl insert' empty (List.filter (fn(k,v) => f v) (listItemsi ma))            List.foldl insert' empty (List.filter (fn(k,v) => f v) (listItemsi ma))
249            List.foldl insert' empty (List.filter f (listItemsi ma))            List.foldl insert' empty (List.filter f (listItemsi ma))
250            </CODE>            </CODE>
251        </SPEC>
252      <SPEC>      <SPEC>
253        <VAL>mapPartial<TY>('a -> 'b option) -> 'a map -> 'b map        <VAL>mapPartial<TY>('a -> 'b option) -> 'a map -> 'b map
254        <VAL>mapPartiali<TY>((Key.ord_key * 'a) -> 'b option) -> 'a map -> 'b map        <VAL>mapPartiali<TY>((Key.ord_key * 'a) -> 'b option) -> 'a map -> 'b map
# Line 256  Line 275 
275            <CODE>            <CODE>
276            fun mapPartial f ma = mapPartiali (fn (_, item) => f item) ma            fun mapPartial f ma = mapPartiali (fn (_, item) => f item) ma
277            </CODE>            </CODE>
278        </SPEC>
279        <SPECBREAK NEWLINE>
280        <SPEC>
281          <VAL>exists<TY>('a -> bool) -> 'a map -> bool</TY>
282          <VAL>existsi<TY>((Key.ord_key * 'a) -> bool) -> 'a map -> bool</TY>
283            <COMMENT>
284              <PROTOTY>
285              exists <ARG>pred</ARG> <ARG/m/
286              </PROTOTY>
287              applies <ARG>pred</ARG> to each element <ARG/x/ of the map
288              <ARG/m/, in key order, until <CD/<ARG>pred</ARG> <ARG/x// evaluates to
289              <CD>true</>; it returns <CD>true</> if
290              such an <ARG/x/ exists and <CD>false</> otherwise.
291              It is equivalent to
292              <CD><VALREF STRID="List"/exists/ <ARG>pred</ARG> (<VALREF>items</VALREF> <ARG/m/)</CD>.
293            </COMMENT>
294        </SPEC>
295        <SPEC>
296          <VAL>all<TY>('a -> bool) -> 'a map -> bool</TY>
297          <VAL>alli<TY>((Key.ord_key * 'a) -> bool) -> 'a map -> bool</TY>
298            <COMMENT>
299              <PROTOTY>
300              all <ARG>pred</ARG> <ARG/m/
301              </PROTOTY>
302              applies <ARG>pred</ARG> to each element <ARG/x/ of the map <ARG/m/, in key order,
303              until <CD/<ARG>pred</ARG> <ARG/x// evaluates to <CD>false</>; it returns <CD>false</>
304              if such an <ARG/x/ exists and <CD>true</> otherwise.
305              It is equivalent to
306              <CD><VALREF STRID="List"/all/ <ARG>pred</ARG> (<VALREF>items</VALREF> <ARG/m/)</CD>.
307            </COMMENT>
308        </SPEC>
309    <SIGINSTANCE OPAQUE> <ID> IntBinaryMap    <SIGINSTANCE OPAQUE> <ID> IntBinaryMap
310     <WHERETYPE><ID>Key.ord_key<TY>Int.int     <WHERETYPE><ID>Key.ord_key<TY>Int.int
311     <COMMENT>     <COMMENT>

Legend:
Removed from v.4069  
changed lines
  Added in v.4070

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