Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/smlnj-lib/Util/hash-string.sml
ViewVC logotype

Diff of /sml/trunk/src/smlnj-lib/Util/hash-string.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1717, Thu Nov 25 04:11:57 2004 UTC revision 1718, Thu Dec 2 22:48:18 2004 UTC
# Line 6  Line 6 
6  structure HashString : sig  structure HashString : sig
7    
8      val hashString : string -> word      val hashString : string -> word
9        val hashString' : substring -> word
10    
11    end = struct    end = struct
12    
# Line 21  Line 22 
22   * in STL.   * in STL.
23   *)   *)
24    
25      fun hashString s = CharVector.foldl hashChar 0w0 s      (* fun hashString s = CharVector.foldl hashChar 0w0 s *)
26        local
27            fun x + y = Word.toIntX (Word.+ (Word.fromInt x, Word.fromInt y))
28            val sub = Unsafe.CharVector.sub
29            fun hash (s, i0, e) =
30                let fun loop (h, i) =
31                        if i >= e then h
32                        else loop (hashChar (sub (s, i), h), i + 1)
33                in loop (0w0, i0)
34                end
35        in
36            fun hashString s = hash (s, 0, size s)
37            fun hashString' ss =
38                let val (s, i0, len) = Substring.base ss
39                in hash (s, i0, i0 + len)
40                end
41        end
42    end (* HashString *)    end (* HashString *)

Legend:
Removed from v.1717  
changed lines
  Added in v.1718

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