Christophe Taton wrote:
I did not find any general set data structure included in the standard
Oz modules (like the one we find in java of c/c++)?
Is there any? and if not, are there valuable reasons for this?

No, there is no such a thing. The reason is: lack of manpower to implement it (and some limitations in the virtual machines.)

Of course I can implement a set over a standard linked list, but when
efficiency is an issue, this solution does not help anymore.
The main issue appears to me to be the way to get a hash code for any
value. Did someone already try to provide such features?

There is an easy implementation sets with dictionaries if the values in the set are "features". A feature is either a number, an atom, or a name. Only those values can be used to index records and dictionaries. Here is a small prototype that gives you the idea:

   fun {NewSet} {NewDictionary} end
   fun {IsEmptySet S} {Dictionary.isEmpty S} end

   fun {IsInSet S X} {Dictionary.member S X} end
   proc {InsertInSet S X} {Dictionary.put S X unit} end
   proc {RemoveFromSet S X} {Dictionary.remove S X} end

   fun {SetToList S} {Dictionary.keys S} end
   proc {ListToSet L ?S}
      S={NewSet}
      for X in L do {InsertInSet S X} end
   end

You can then use those procedures to implement union, intersection, and other set operations.

If the values you consider are not features, then there is no simple solutions. There is no built-in hash for records, because records are by nature partial values (fields may be undetermined). Procedures, classes, chunks could have a built-in hash, but this is currently not implemented.

I hope this helps.

Cheers,
raph
_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to