Commit | Line | Data |
---|---|---|
7f918cf1 CE |
1 | (* Copyright (C) 2009 Matthew Fluet. |
2 | * Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh | |
3 | * Jagannathan, and Stephen Weeks. | |
4 | * | |
5 | * MLton is released under a BSD-style license. | |
6 | * See the file MLton-LICENSE for details. | |
7 | *) | |
8 | ||
9 | signature HASH_SET = | |
10 | sig | |
11 | type 'a t | |
12 | ||
13 | val fold: 'a t * 'b * ('a * 'b -> 'b) -> 'b | |
14 | val forall: 'a t * ('a -> bool) -> bool | |
15 | val foreach: 'a t * ('a -> unit) -> unit | |
16 | val fromList: 'a list * {hash: 'a -> word, equals: 'a * 'a -> bool} -> 'a t | |
17 | (* insertIfNew (s, h, p, f, g) looks in the set s for an entry with hash h | |
18 | * satisfying predicate p. If the entry is there, it is returned after | |
19 | * being applied to g. Otherwise, the function f is called to create a | |
20 | * new entry, which is inserted and returned. | |
21 | * NOTE: f must not modify the hash set during its evaluation. | |
22 | *) | |
23 | val insertIfNew: | |
24 | 'a t * word * ('a -> bool) * (unit -> 'a) * ('a -> unit) -> 'a | |
25 | val layout: ('a -> Layout.t) -> 'a t -> Layout.t | |
26 | (* lookupOrInsert (s, h, p, f) looks in the set s for an entry with hash h | |
27 | * satisfying predicate p. If the entry is there, it is returned. | |
28 | * Otherwise, the function f is called to create a new entry, which is | |
29 | * inserted and returned. | |
30 | * NOTE: f must not modify the hash set during its evaluation. | |
31 | *) | |
32 | val lookupOrInsert: 'a t * word * ('a -> bool) * (unit -> 'a) -> 'a | |
33 | val new: {hash: 'a -> word} -> 'a t | |
34 | (* newOfSize {hash, size} | |
35 | * creates a table that can handle size elements without resizing. | |
36 | *) | |
37 | val newOfSize: {hash: 'a -> word, | |
38 | size: int} -> 'a t | |
39 | val peek: 'a t * word * ('a -> bool) -> 'a option | |
40 | (* remove an entry. Error if it's not there. *) | |
41 | val remove: 'a t * word * ('a -> bool) -> unit | |
42 | (* removeAll (s, p) removes all entries from s that satisfy predicate p. *) | |
43 | val removeAll: 'a t * ('a -> bool) -> unit | |
44 | val size: 'a t -> int | |
45 | val stats: unit -> Layout.t | |
46 | val stats': 'a t -> Layout.t | |
47 | val toList: 'a t -> 'a list | |
48 | end | |
49 | ||
50 | ||
51 | functor TestHashSet (S: HASH_SET): sig end = | |
52 | struct | |
53 | ||
54 | open S | |
55 | ||
56 | val _ = Assert.assert("TestHashSet", fn () => true) | |
57 | ||
58 | end |