From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA26036; Sun, 25 Jul 2004 18:26:13 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA26223 for ; Sun, 25 Jul 2004 18:26:11 +0200 (MET DST) Received: from mz2.forethought.net (mzpi4.forethought.net [216.241.36.13]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i6PGQ9SH009026 for ; Sun, 25 Jul 2004 18:26:10 +0200 Received: from [216.241.35.41] (helo=swordfish) by mz2.forethought.net with esmtp (Exim 4.30) id 1BolpA-0001Dw-OY for caml-list@inria.fr; Sun, 25 Jul 2004 10:26:08 -0600 Received: from matt by swordfish with local (Exim 3.35 #1 (Debian)) id 1BolpA-0006wl-00 for ; Sun, 25 Jul 2004 10:26:08 -0600 Date: Sun, 25 Jul 2004 10:26:08 -0600 From: Matt Gushee To: caml-list@inria.fr Subject: Re: [Caml-list] Map + Set Message-ID: <20040725162608.GA26605@swordfish> Reply-To: Matt Gushee Mail-Followup-To: caml-list@inria.fr References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.27i X-Miltered: at concorde with ID 4103DF22.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; gushee:01 mgushee:01 havenrock:01 caml-list:01 2004:99 val:01 elt:01 elt:01 mli:01 struct:01 struct:01 functor:01 sometype:01 gushee:01 englewood:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sun, Jul 25, 2004 at 04:17:55PM +0800, Martin Jambon wrote: > > I need a functional data structure that has a decent efficiency (i.e. > not lists) and can represent `sets of named containers' so that I can > find a container in a set, remove it from the set, update it and put it > back into the set. > > val find : elt -> t -> elt (* yes! *) > > Finally I just copy-pasted set.mli and set.ml and inserted a find > function... but is there a better solution? What I did when faced with a similar problem was: module MySet = struct module BaseSet = Set.Make( struct .... end) include BaseSet let find elt set = ... end Now of course that will only handle one data type. If you want polymorphism, I suppose you could try something like: module MySet = struct module Make = functor(SomeMod:SOMETYPE) -> struct include Set.Make let find elt set = ... end .... end Though I haven't tried the more general approach. -- Matt Gushee When a nation follows the Way, Englewood, Colorado, USA Horses bear manure through mgushee@havenrock.com its fields; http://www.havenrock.com/ When a nation ignores the Way, Horses bear soldiers through its streets. --Lao Tzu (Peter Merel, trans.) ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners