diff options
author | Paweł Dybiec <pdybiec@stud.cs.uni.wroc.pl> | 2018-10-30 15:32:56 +0100 |
---|---|---|
committer | Paweł Dybiec <pdybiec@stud.cs.uni.wroc.pl> | 2018-10-30 15:32:56 +0100 |
commit | b798ac29c37299b2f761243ae92ab8f7c4c4d7f1 (patch) | |
tree | eb9b9cc9be294fe5bd3acf9a342098ffc0ea06e5 /source/xi_lib/hashset.ml |
Initial commit
Diffstat (limited to 'source/xi_lib/hashset.ml')
-rw-r--r-- | source/xi_lib/hashset.ml | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/xi_lib/hashset.ml b/source/xi_lib/hashset.ml new file mode 100644 index 0000000..455ba81 --- /dev/null +++ b/source/xi_lib/hashset.ml @@ -0,0 +1,30 @@ + +type 'a t = ('a, unit) Hashtbl.t + +let create () : 'a t = Hashtbl.create 101 + +let clear = Hashtbl.clear + +let add t x = Hashtbl.replace t x () + +let mem = Hashtbl.mem + +let to_seq t = Hashtbl.to_seq_keys t + +let length t = Hashtbl.length t + +let remove t v = Hashtbl.remove t v + +let iter f t = + let g k _ = f k in + Hashtbl.iter g t + + +let fold f t acc = + let g k () = f k in + Hashtbl.fold g t acc + +let of_seq seq : 'a t = + let result = create () in + Seq.iter (add result) seq; + result \ No newline at end of file |