Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Why3
why3
Commits
43d448bf
Commit
43d448bf
authored
Oct 12, 2012
by
Jean-Christophe Filliâtre
Browse files
hash tables: resize (in progress)
parent
c859a97a
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
modules/hashtbl.mlw
View file @
43d448bf
...
...
@@ -132,6 +132,23 @@ module HashtblImpl
= h.size <- 0;
Array.fill h.data 0 (Array.length h.data) Nil
let resize (h: t 'a)
ensures { forall k: key. h[k] = (old h)[k] }
= let odata = h.data in
let osize = Array.length odata in
let nsize = 2 * osize + 1 in
let ndata = Array.make nsize Nil in
let rec rehash l = match l with
| Nil -> ()
| Cons (k, v) r ->
let b = bucket k nsize in
ndata[b] <- Cons (k, v) (Array.([]) ndata b);
rehash r
end
in
for i = 0 to osize - 1 do rehash (Array.([]) odata i) done;
h.data <- ndata
lemma extract_neq:
forall k k': key, v: 'a, l: list (key, 'a).
k <> k' -> extract k' l = extract k' (Cons (k, v) l)
...
...
@@ -142,4 +159,13 @@ module HashtblImpl
= let b = bucket k (Array.length h.data) in
h.data[b] <- Cons (k, v) (Array.([]) h.data b)
(*
let add (h: t 'a) (k: key) (v: 'a) =
ensures { h[k] = Cons v (old h)[k] /\
forall k': key. k' <> k -> h[k'] = (old h)[k'] }
let b = bucket k (Array.length h.data) in
h.data[b] <- Cons (k, v) (Array.([]) h.data b);
if h.size > 2 * Array.length h.data then resize h
*)
end
modules/hashtbl/why3session.xml
View file @
43d448bf
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment