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 2 - (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 :     val insert : ('a, 'b) hash_table -> ('a * 'b) -> unit
26 :     (* Insert an item. If the key already has an item associated with it,
27 :     * then the old item is discarded.
28 :     *)
29 :    
30 :     val lookup : ('a, 'b) hash_table -> 'a -> 'b
31 :     (* Find an item, the table's exception is raised if the item doesn't exist *)
32 :    
33 :     val find : ('a, 'b) hash_table -> 'a -> 'b option
34 :     (* Look for an item, return NONE if the item doesn't exist *)
35 :    
36 :     val remove : ('a, 'b) hash_table -> 'a -> 'b
37 :     (* Remove an item, returning the item. The table's exception is raised if
38 :     * the item doesn't exist.
39 :     *)
40 :    
41 :     val numItems : ('a, 'b) hash_table -> int
42 :     (* Return the number of items in the table *)
43 :    
44 :     val listItems : ('a, 'b) hash_table -> 'b list
45 :     val listItemsi : ('a, 'b) hash_table -> ('a * 'b) list
46 :     (* Return a list of the items (and their keys) in the table *)
47 :    
48 :     val app : ('b -> unit) -> ('a, 'b) hash_table -> unit
49 :     val appi : (('a * 'b) -> unit) -> ('a, 'b) hash_table -> unit
50 :     (* Apply a function to the entries of the table *)
51 :    
52 :     val map : ('b -> 'c) -> ('a, 'b) hash_table -> ('a, 'c) hash_table
53 :     val mapi : (('a * 'b) -> 'c) -> ('a, 'b) hash_table -> ('a, 'c) hash_table
54 :     (* Map a table to a new table that has the same keys *)
55 :    
56 :     val fold : (('b *'c) -> 'c) -> 'c -> ('a, 'b) hash_table -> 'c
57 :     val foldi : (('a * 'b * 'c) -> 'c) -> 'c -> ('a, 'b) hash_table -> 'c
58 :     (* Fold a function over the elements of a table *)
59 :    
60 :     val filter : ('b -> bool) -> ('a, 'b) hash_table -> unit
61 :     val filteri : (('a * 'b) -> bool) -> ('a, 'b) hash_table -> unit
62 :     (* remove any hash table items that do not satisfy the given
63 :     * predicate.
64 :     *)
65 :    
66 :     val copy : ('a, 'b) hash_table -> ('a, 'b) hash_table
67 :     (* Create a copy of a hash table *)
68 :    
69 :     val bucketSizes : ('a, 'b) hash_table -> int list
70 :     (* returns a list of the sizes of the various buckets. This is to
71 :     * allow users to gauge the quality of their hashing function.
72 :     *)
73 :    
74 :     end (* HASH_TABLE *)

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