Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
why3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
120
Issues
120
List
Boards
Labels
Service Desk
Milestones
Merge Requests
17
Merge Requests
17
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Why3
why3
Commits
3aae4bbd
Commit
3aae4bbd
authored
May 17, 2011
by
Jean-Christophe Filliâtre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new module for hash tables (in progress)
parent
5b1a1708
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
4 deletions
+63
-4
modules/array.mlw
modules/array.mlw
+13
-4
modules/hashtbl.mlw
modules/hashtbl.mlw
+50
-0
No files found.
modules/array.mlw
View file @
3aae4bbd
...
...
@@ -19,10 +19,19 @@ module Array
{ 0 <= i < length a } unit writes a { a = (old a)[i <- v] }
(* unsafe get/set operations with no precondition *)
parameter unsafe_get : a:array 'a -> i:int ->
{ } 'a reads a { result = a[i] }
parameter unsafe_set : a:array 'a -> i:int -> v:'a ->
{ } unit writes a { a = (old a)[i <- v] }
exception OutOfBounds
parameter defensive_get: a:array 'a -> i:int ->
{ }
'a reads a raises OutOfBounds
{ 0 <= i < length a and result = a[i] }
| OutOfBounds -> { i < 0 or i >= length a }
parameter defensive_set : a:array 'a -> i:int -> v:'a ->
{ }
unit writes a raises OutOfBounds
{ 0 <= i < length a and a = (old a)[i <- v] }
| OutOfBounds -> { i < 0 or i >= length a }
parameter length : a:array 'a -> {} int { result = a.length }
...
...
modules/hashtbl.mlw
0 → 100644
View file @
3aae4bbd
module Hashtbl
use import list.List
use import map.Map
type key
type t 'a model {| mutable contents: map key (list 'a) |}
logic ([]) (h: t 'a) (k: key) : list 'a = get h k
parameter create: n:int ->
{} t 'a { forall k: key. result[k] = Nil }
parameter clear: h: t 'a ->
{} unit writes h { forall k: key. h[k] = Nil }
parameter add: h: t 'a -> k: key -> v: 'a ->
{}
unit writes h
{ h[k] = Cons v (old h)[k] and
forall k': key. k' <> k -> h[k'] = (old h)[k'] }
(*
val copy : ('a, 'b) t -> ('a, 'b) t
val find : ('a, 'b) t -> 'a -> 'b
val find_all : ('a, 'b) t -> 'a -> 'b list
val mem : ('a, 'b) t -> 'a -> bool
val remove : ('a, 'b) t -> 'a -> unit
val replace : ('a, 'b) t -> 'a -> 'b -> unit
val iter : ('a -> 'b -> unit) -> ('a, 'b) t -> unit
val fold : ('a -> 'b -> 'c -> 'c) -> ('a, 'b) t -> 'c -> 'c
val length : ('a, 'b) t -> int
*)
end
(*
Local Variables:
compile-command: "unset LANG; make -C .. modules/hashtbl"
End:
*)
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