[m-rev.] won't be committed: using set_tree234s to implement sets

Zoltan Somogyi zs at csse.unimelb.edu.au
Tue Sep 29 15:36:40 AEST 2009


See me email in mercury-developers. I am posting the diff just to record it.

Zoltan.

cvs diff: Diffing library
Index: library/set.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/set.m,v
retrieving revision 1.86
diff -u -b -r1.86 set.m
--- library/set.m	20 Feb 2009 08:19:05 -0000	1.86
+++ library/set.m	23 Sep 2009 05:32:07 -0000
@@ -11,8 +11,7 @@
 % Stability: high.
 % 
 % This module provides a set ADT.
-% The implementation represents sets using ordered lists.
-% This file just calls the equivalent predicates in set_ordlist.
+% The implementation just calls the equivalent predicates in set_tree234.
 % 
 %--------------------------------------------------------------------------%
 %--------------------------------------------------------------------------%
@@ -29,7 +28,7 @@
 
     % `set.init(Set)' is true iff `Set' is an empty set.
     %
-:- pred set.init(set(T)::uo) is det.
+:- pred set.init(set(T)::out) is det.
 :- func set.init = set(T).
 
     % `set.list_to_set(List, Set)' is true iff `Set' is the set
@@ -351,101 +350,101 @@
 
 :- implementation.
 
-:- import_module set_ordlist.
+:- import_module set_tree234.
 
-:- type set(T) ==   set_ordlist(T).
+:- type set(T) ==   set_tree234(T).
 
 set.list_to_set(List, Set) :-
-    set_ordlist.list_to_set(List, Set).
+    Set = set_tree234.list_to_set(List).
 
-set.from_list(List) = set_ordlist.from_list(List).
+set.from_list(List) = set_tree234.list_to_set(List).
 
-set.set(List) = set_ordlist.from_list(List).
+set.set(List) = set_tree234.list_to_set(List).
 
 set.sorted_list_to_set(List, Set) :-
-    set_ordlist.sorted_list_to_set(List, Set).
+    Set = set_tree234.sorted_list_to_set(List).
 
-set.from_sorted_list(List) = set_ordlist.from_sorted_list(List).
+set.from_sorted_list(List) = set_tree234.sorted_list_to_set(List).
 
 set.to_sorted_list(Set, List) :-
-    set_ordlist.to_sorted_list(Set, List).
+    List = set_tree234.to_sorted_list(Set).
 
 set.insert_list(Set0, List, Set) :-
-    set_ordlist.insert_list(Set0, List, Set).
+    set_tree234.insert_list(List, Set0, Set).
 
 set.insert(Set0, X, Set) :-
-    set_ordlist.insert(Set0, X, Set).
+    set_tree234.insert(X, Set0, Set).
 
 set.init(Set) :-
-    set_ordlist.init(Set).
+    Set = set_tree234.init.
 
 set.singleton_set(Set, X) :-
-    set_ordlist.singleton_set(Set, X).
+    set_tree234.singleton_set(X, Set).
 
 set.equal(SetA, SetB) :-
-    set_ordlist.equal(SetA, SetB).
+    set_tree234.equal(SetA, SetB).
 
 set.empty(Set) :-
-    set_ordlist.empty(Set).
+    set_tree234.empty(Set).
 
 set.non_empty(Set) :-
-    \+ set_ordlist.empty(Set).
+    \+ set_tree234.empty(Set).
 
 set.subset(SetA, SetB) :-
-    set_ordlist.subset(SetA, SetB).
+    set_tree234.subset(SetA, SetB).
 
 set.superset(SetA, SetB) :-
-    set_ordlist.superset(SetA, SetB).
+    set_tree234.superset(SetA, SetB).
 
 :- pragma promise_equivalent_clauses(set.member/2).
 
 set.member(X::in, Set::in) :-
-    set_ordlist.is_member(X, Set, yes).
+    set_tree234.is_member(Set, X, yes).
 set.member(X::out, Set::in) :-
-    set_ordlist.member(X, Set).
+    set_tree234.member(Set, X).
 
 set.is_member(X, Set, Result) :-
-    set_ordlist.is_member(X, Set, Result).
+    set_tree234.is_member(Set, X, Result).
 
 set.contains(Set, X) :-
-    set_ordlist.contains(Set, X).
+    set_tree234.contains(Set, X).
 
 set.delete_list(Set0, List, Set) :-
-    set_ordlist.delete_list(Set0, List, Set).
+    set_tree234.delete_list(List, Set0, Set).
 
 set.delete(Set0, X, Set) :-
-    set_ordlist.delete(Set0, X, Set).
+    set_tree234.delete(X, Set0, Set).
 
 set.remove_list(Set0, List, Set) :-
-    set_ordlist.remove_list(Set0, List, Set).
+    set_tree234.remove_list(List, Set0, Set).
 
 set.remove(Set0, X, Set) :-
-    set_ordlist.remove(Set0, X, Set).
+    set_tree234.remove(X, Set0, Set).
 
 set.remove_least(Set0, X, Set) :-
-    set_ordlist.remove_least(Set0, X, Set).
+    set_tree234.remove_least(X, Set0, Set).
 
 set.union(SetA, SetB, Set) :-
-    set_ordlist.union(SetA, SetB, Set).
+    set_tree234.union(SetA, SetB, Set).
 
-set.union_list(Sets) = set_ordlist.union_list(Sets).
+set.union_list(Sets) = set_tree234.union_list(Sets).
 
 set.power_union(Sets, Set) :-
-    set_ordlist.power_union(Sets, Set).
+    set_tree234.power_union(Sets, Set).
 
 set.intersect(SetA, SetB, Set) :-
-    set_ordlist.intersect(SetA, SetB, Set).
+    set_tree234.intersect(SetA, SetB, Set).
 
 set.power_intersect(Sets, Set) :-
-    set_ordlist.power_intersect(Sets, Set).
+    Set = set_tree234.power_intersect(Sets).
 
-set.intersect_list(Sets) = set_ordlist.intersect_list(Sets).
+set.intersect_list(Sets) = set_tree234.intersect_list(Sets).
 
 set.difference(SetA, SetB, Set) :-
-    set_ordlist.difference(SetA, SetB, Set).
+    set_tree234.difference(SetA, SetB, Set).
 
 set.count(Set, Count) :-
-    set_ordlist.count(Set, Count).
+    Count = set_tree234.count(Set).
 
 %--------------------------------------------------------------------------%
 %--------------------------------------------------------------------------%
@@ -537,7 +536,7 @@
     list.foldl4(F, set.to_sorted_list(S), !A, !B, !C, !D).
 
 set.divide(P, Set, TruePart, FalsePart) :-
-    set_ordlist.divide(P, Set, TruePart, FalsePart).
+    set_tree234.divide(P, Set, TruePart, FalsePart).
 
 set.divide_by_set(DivideBySet, Set, TruePart, FalsePart) :-
-    set_ordlist.divide_by_set(DivideBySet, Set, TruePart, FalsePart).
+    set_tree234.divide_by_set(DivideBySet, Set, TruePart, FalsePart).
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list