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 /sml/trunk/src/eXene/styles/quark.sml
ViewVC logotype

Annotation of /sml/trunk/src/eXene/styles/quark.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 651 - (view) (download)

1 : monnier 2 (* quark.sml
2 :     *
3 :     * COPYRIGHT (c) 1994 by AT&T Bell Laboratories. See COPYRIGHT file for details.
4 :     *
5 :     * Strings with fast inequality operations. This should probably be replaced
6 :     * with "names," but there are problems with creating names that are statically
7 :     * initialized in CML. Once there is a "CML shell," we can replace this by
8 :     * the CML_Name structure.
9 :     *)
10 :    
11 :     structure Quark :> QUARK =
12 :     struct
13 :    
14 :     datatype quark = Q of {str : string, hash : word}
15 :    
16 :     fun quark s = Q{str = s, hash = HashString.hashString s}
17 :    
18 :     fun stringOf (Q{str, ...}) = str
19 :    
20 :     fun same (Q{str=s1, hash=h1}, Q{str=s2, hash=h2}) =
21 :     (h1 = h2) andalso (s1 = s2)
22 :    
23 :     fun hash (Q{hash, ...}) = hash
24 :    
25 :     fun cmp (Q{str=s1, hash=h1}, Q{str=s2, hash=h2}) =
26 :     if (h1 < h2)
27 :     then LESS
28 :     else if (h2 < h1)
29 :     then GREATER
30 :     else String.compare(s1, s2)
31 :    
32 :     end;

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