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/hash-table-sig.sml
ViewVC logotype

Annotation of /smlnj-lib/branches/rt-transition/Util/hash-table-sig.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 651 - (view) (download)
Original Path: sml/trunk/src/smlnj-lib/Util/hash-table-sig.sml

1 : monnier 2 (* hash-table-sig.sml
2 :     *
3 :     * COPYRIGHT (c) 1993 by AT&T Bell Laboratories.
4 :     *
5 :     * The signature of the polymorphic hash table structure.
6 :     *
7 :     * AUTHOR: John Reppy
8 :     * AT&T Bell Laboratories
9 :     * Murray Hill, NJ 07974
10 :     * jhr@research.att.com
11 :     *)
12 :    
13 :     signature HASH_TABLE =
14 :     sig
15 :    
16 :     type ('a, 'b) hash_table
17 :     (* type of hash table mapping 'a to 'b *)
18 :    
19 :     val mkTable : (('a -> word) * (('a * 'a) -> bool)) -> (int * exn)
20 :     -> ('a,'b) hash_table
21 :     (* Given a hashing function and an equality predicate, create a new table;
22 :     * the int is a size hint and the exception is to be raised by find.
23 :     *)
24 :    
25 : monnier 8 val clear : ('a, 'b) hash_table -> unit
26 :     (* remove all elements from the table *)
27 :    
28 : monnier 2 val insert : ('a, 'b) hash_table -> ('a * 'b) -> unit
29 :     (* Insert an item. If the key already has an item associated with it,
30 :     * then the old item is discarded.
31 :     *)
32 :    
33 :     val lookup : ('a, 'b) hash_table -> 'a -> 'b
34 :     (* Find an item, the table's exception is raised if the item doesn't exist *)
35 :    
36 :     val find : ('a, 'b) hash_table -> 'a -> 'b option
37 :     (* Look for an item, return NONE if the item doesn't exist *)
38 :    
39 :     val remove : ('a, 'b) hash_table -> 'a -> 'b
40 :     (* Remove an item, returning the item. The table's exception is raised if
41 :     * the item doesn't exist.
42 :     *)
43 :    
44 :     val numItems : ('a, 'b) hash_table -> int
45 :     (* Return the number of items in the table *)
46 :    
47 :     val listItems : ('a, 'b) hash_table -> 'b list
48 :     val listItemsi : ('a, 'b) hash_table -> ('a * 'b) list
49 :     (* Return a list of the items (and their keys) in the table *)
50 :    
51 :     val app : ('b -> unit) -> ('a, 'b) hash_table -> unit
52 :     val appi : (('a * 'b) -> unit) -> ('a, 'b) hash_table -> unit
53 :     (* Apply a function to the entries of the table *)
54 :    
55 :     val map : ('b -> 'c) -> ('a, 'b) hash_table -> ('a, 'c) hash_table
56 :     val mapi : (('a * 'b) -> 'c) -> ('a, 'b) hash_table -> ('a, 'c) hash_table
57 :     (* Map a table to a new table that has the same keys *)
58 :    
59 :     val fold : (('b *'c) -> 'c) -> 'c -> ('a, 'b) hash_table -> 'c
60 :     val foldi : (('a * 'b * 'c) -> 'c) -> 'c -> ('a, 'b) hash_table -> 'c
61 :     (* Fold a function over the elements of a table *)
62 :    
63 : jhr 596 val modify : ('b -> 'b) -> ('a, 'b) hash_table -> unit
64 :     val modifyi : (('a * 'b) -> 'b) -> ('a, 'b) hash_table -> unit
65 :     (* modify the hash-table items in place *)
66 :    
67 : monnier 2 val filter : ('b -> bool) -> ('a, 'b) hash_table -> unit
68 :     val filteri : (('a * 'b) -> bool) -> ('a, 'b) hash_table -> unit
69 :     (* remove any hash table items that do not satisfy the given
70 :     * predicate.
71 :     *)
72 :    
73 :     val copy : ('a, 'b) hash_table -> ('a, 'b) hash_table
74 :     (* Create a copy of a hash table *)
75 :    
76 :     val bucketSizes : ('a, 'b) hash_table -> int list
77 :     (* returns a list of the sizes of the various buckets. This is to
78 :     * allow users to gauge the quality of their hashing function.
79 :     *)
80 :    
81 :     end (* HASH_TABLE *)

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