[m-rev.] diff: add bimap.count/1
Julien Fischer
jfischer at opturion.com
Fri May 17 14:25:52 AEST 2013
Branches: 13.05, master
------------------------------
Add the function bimap.count/1.
library/bimap.m:
Add the above function.
Fix the wording of a function description.
NEWS:
Add a section for 13.05.1 and mention the above change in it.
Julien.
diff --git a/NEWS b/NEWS
index 19e9548..b3bc8c5 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,11 @@
+NEWS for Mercury 13.05.1
+------------------------
+
+Changes to the Mercury standard library:
+
+* We have added the function bimap.count/1.
+
+
NEWS for Mercury 13.05
----------------------
diff --git a/library/bimap.m b/library/bimap.m
index 7110213..4fd8a5b 100644
--- a/library/bimap.m
+++ b/library/bimap.m
@@ -203,6 +203,10 @@
:- pred bimap.overlay(bimap(K, V)::in, bimap(K, V)::in, bimap(K, V)::out)
is det.
+ % Count the number of key-value pairs in the bimap.
+ %
+:- func bimap.count(bimap(K, V)) = int.
+
% Convert a bimap to an association list.
%
:- func bimap.to_assoc_list(bimap(K, V)) = assoc_list(K, V).
@@ -217,7 +221,7 @@
is semidet.
% As above but throws an exception instead of failing if the
- % association list does not implicitly defined a bijection.
+ % association list does not implicitly define a bijection.
%
:- func bimap.det_from_assoc_list(assoc_list(K, V)) = bimap(K, V).
:- pred bimap.det_from_assoc_list(assoc_list(K, V)::in, bimap(K, V)::out)
@@ -563,6 +567,10 @@ bimap.overlay_2([Key - Value | KeysValues], !BM) :-
bimap.set(Key, Value, !BM),
bimap.overlay_2(KeysValues, !BM).
+bimap.count(BM) = Count :-
+ BM = bimap(Forward, _),
+ Count = map.count(Forward).
+
bimap.to_assoc_list(BM) = AL :-
bimap.to_assoc_list(BM, AL).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20130517/a1cf8172/attachment.html>
More information about the reviews
mailing list