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/trunk/Util/mono-hash2-table-sig.sml
ViewVC logotype

Annotation of /smlnj-lib/trunk/Util/mono-hash2-table-sig.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4860 - (view) (download)

1 : monnier 2 (* mono-hash2-table-sig.sml
2 :     *
3 : jhr 4860 * COPYRIGHT (c) 2018 The Fellowship of SML/NJ (http://www.smlnj.org)
4 :     * All rights reserved.
5 : monnier 2 *
6 :     * Hash tables that are keyed by two keys (in different domains).
7 :     *
8 :     * AUTHOR: John Reppy
9 : jhr 4860 * University of Chicago
10 :     * https://cs.uchicago.edu/~jhr
11 : monnier 2 *)
12 :    
13 :     signature MONO_HASH2_TABLE =
14 :     sig
15 :    
16 :     structure Key1 : HASH_KEY
17 :     structure Key2 : HASH_KEY
18 :    
19 :     type 'a hash_table
20 :    
21 :     val mkTable : (int * exn) -> 'a hash_table
22 :     (* Create a new table; the int is a size hint and the exception
23 :     * is to be raised by find.
24 :     *)
25 :    
26 : monnier 8 val clear : 'a hash_table -> unit
27 :     (* remove all elements from the table *)
28 :    
29 : monnier 2 val insert : 'a hash_table -> (Key1.hash_key * Key2.hash_key * 'a) -> unit
30 :     (* Insert an item. If the key already has an item associated with it,
31 :     * then the old item is discarded.
32 :     *)
33 :    
34 : jhr 816 val inDomain1 : 'a hash_table -> Key1.hash_key -> bool
35 :     val inDomain2 : 'a hash_table -> Key2.hash_key -> bool
36 :     (* return true, if the key is in the domain of the table *)
37 :    
38 : monnier 2 val lookup1 : 'a hash_table -> Key1.hash_key -> 'a
39 :     val lookup2 : 'a hash_table -> Key2.hash_key -> 'a
40 :     (* Find an item, the table's exception is raised if the item doesn't exist *)
41 :    
42 :     val find1 : 'a hash_table -> Key1.hash_key -> 'a option
43 :     val find2 : 'a hash_table -> Key2.hash_key -> 'a option
44 :     (* Look for an item, return NONE if the item doesn't exist *)
45 :    
46 :     val remove1 : 'a hash_table -> Key1.hash_key -> 'a
47 :     val remove2 : 'a hash_table -> Key2.hash_key -> 'a
48 :     (* Remove an item, returning the item. The table's exception is raised if
49 :     * the item doesn't exist.
50 :     *)
51 :    
52 :     val numItems : 'a hash_table -> int
53 :     (* Return the number of items in the table *)
54 :    
55 :     val listItems : 'a hash_table -> 'a list
56 :     val listItemsi : 'a hash_table -> (Key1.hash_key * Key2.hash_key * 'a) list
57 :     (* Return a list of the items (and their keys) in the table *)
58 :    
59 :     val app : ('a -> unit) -> 'a hash_table -> unit
60 :     val appi : ((Key1.hash_key * Key2.hash_key * 'a) -> unit) -> 'a hash_table
61 :     -> unit
62 :     (* Apply a function to the entries of the table *)
63 :    
64 :     val map : ('a -> 'b) -> 'a hash_table -> 'b hash_table
65 :     val mapi : ((Key1.hash_key * Key2.hash_key * 'a) -> 'b) -> 'a hash_table
66 :     -> 'b hash_table
67 :     (* Map a table to a new table that has the same keys *)
68 :    
69 :     val fold : (('a * 'b) -> 'b) -> 'b -> 'a hash_table -> 'b
70 :     val foldi : ((Key1.hash_key * Key2.hash_key * 'a * 'b) -> 'b) -> 'b
71 :     -> 'a hash_table -> 'b
72 :    
73 :     (** Also mapPartial?? *)
74 :     val filter : ('a -> bool) -> 'a hash_table -> unit
75 :     val filteri : ((Key1.hash_key * Key2.hash_key * 'a) -> bool) -> 'a hash_table
76 :     -> unit
77 :     (* remove any hash table items that do not satisfy the given
78 :     * predicate.
79 :     *)
80 :    
81 :     val copy : 'a hash_table -> 'a hash_table
82 :     (* Create a copy of a hash table *)
83 :    
84 :     val bucketSizes : 'a hash_table -> (int list * int list)
85 :     (* returns a list of the sizes of the various buckets. This is to
86 :     * allow users to gauge the quality of their hashing function.
87 :     *)
88 :    
89 :     end (* MONO_HASH2_TABLE *)

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