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-table-fn.sml
ViewVC logotype

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

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

sml/branches/SMLNJ/src/smlnj-lib/Util/hash-table-fn.sml revision 8, Sun Jan 18 01:01:29 1998 UTC sml/trunk/src/smlnj-lib/Util/hash-table-fn.sml revision 816, Fri May 4 16:37:36 2001 UTC
# Line 65  Line 65 
65              (* end case *)              (* end case *)
66            end            end
67    
68      (* return true, if the key is in the domain of the table *)
69        fun inDomain (HT{table, ...}) key = let
70              val arr = !table
71              val hash = hashVal key
72              val indx = index (hash, Array.length arr)
73              fun look HTRep.NIL = false
74                | look (HTRep.B(h, k, v, r)) =
75                    ((hash = h) andalso sameKey(key, k)) orelse look r
76              in
77                look (Array.sub (arr, indx))
78              end
79    
80    (* find an item, the table's exception is raised if the item doesn't exist *)    (* find an item, the table's exception is raised if the item doesn't exist *)
81      fun lookup (HT{table, not_found, ...}) key = let      fun lookup (HT{table, not_found, ...}) key = let
82            val arr = !table            val arr = !table
# Line 140  Line 152 
152      fun foldi f init (HT{table, ...}) = HTRep.foldi f init (! table)      fun foldi f init (HT{table, ...}) = HTRep.foldi f init (! table)
153      fun fold f init (HT{table, ...}) = HTRep.fold f init (! table)      fun fold f init (HT{table, ...}) = HTRep.fold f init (! table)
154    
155      (* modify the hash-table items in place *)
156        fun modifyi f (HT{table, ...}) = HTRep.modifyi f (!table)
157        fun modify f (HT{table, ...}) = HTRep.modify f (!table)
158    
159    (* remove any hash table items that do not satisfy the given    (* remove any hash table items that do not satisfy the given
160     * predicate.     * predicate.
161     *)     *)
162      fun filteri pred (HT{table, ...}) = HTRep.filteri pred (! table)      fun filteri pred (HT{table, n_items, ...}) =
163      fun filter pred (HT{table, ...}) = HTRep.filter pred (! table)            n_items := HTRep.filteri pred (! table)
164        fun filter pred (HT{table, n_items, ...}) =
165              n_items := HTRep.filter pred (! table)
166    
167    (* Create a copy of a hash table *)    (* Create a copy of a hash table *)
168      fun copy (HT{table, n_items, not_found}) = HT{      fun copy (HT{table, n_items, not_found}) = HT{

Legend:
Removed from v.8  
changed lines
  Added in v.816

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