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 1731, Wed Dec 15 22:16:53 2004 UTC revision 1732, Thu Dec 16 05:07:47 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        val hashSubstring : substring -> word
11    
12  end = struct  end = struct
13    
# Line 26  Line 27 
27      local      local
28          fun x + y = Word.toIntX (Word.+ (Word.fromInt x, Word.fromInt y))          fun x + y = Word.toIntX (Word.+ (Word.fromInt x, Word.fromInt y))
29          val sub = Unsafe.CharVector.sub          val sub = Unsafe.CharVector.sub
30          fun hash (s, i0, e) =        fun hash (s, i0, e) = let
31              let fun loop (h, i) =              fun loop (h, i) = if i >= e
32                      if i >= e then h                    then h
33                      else loop (hashChar (sub (s, i), h), i + 1)                      else loop (hashChar (sub (s, i), h), i + 1)
34              in loop (0w0, i0)              in
35                  loop (0w0, i0)
36              end              end
37      in      in
38          fun hashString s = hash (s, 0, size s)          fun hashString s = hash (s, 0, size s)
39          fun hashString' ss =      fun hashString' ss = let
40              let val (s, i0, len) = Substring.base ss            val (s, i0, len) = Substring.base ss
41              in hash (s, i0, i0 + len)            in
42              end              hash (s, i0, i0 + len)
43      end      end
44        end (* local *)
45    
46  end (* HashString *)  end (* HashString *)

Legend:
Removed from v.1731  
changed lines
  Added in v.1732

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