git-svn-id: https://projects.brucker.ch/su4sml/svn/infsec-import/trunk/src/su4sml@3114 3260e6d1-4efc-4170-b0a7-36055960796d
This commit is contained in:
parent
2f78b7aeeb
commit
078abb3d2d
|
@ -0,0 +1,30 @@
|
|||
structure HashString =
|
||||
struct
|
||||
fun hashString _ = ()
|
||||
end
|
||||
|
||||
structure HashTable =
|
||||
struct
|
||||
|
||||
|
||||
datatype ('a, 'b) hash_table = HT of {
|
||||
eq_pred : ('a * 'a) -> bool,
|
||||
not_found : exn,
|
||||
table: (('a*'b) list) ref
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
fun mkTable (_, eq) (_, notFound) = HT{
|
||||
eq_pred = eq,
|
||||
not_found = notFound,
|
||||
table = ref ([])
|
||||
}
|
||||
|
||||
|
||||
fun find (HT{table,...}) key =
|
||||
Option.map (fn (a,b) => b) ((List.find (fn (x,y) => x =key) (!table)))
|
||||
fun insert (HT{table,...}) (k,v) = (table:=([(k,v)]@ (!(table))))
|
||||
|
||||
end
|
Loading…
Reference in New Issue