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 LAA05731; Sat, 8 Nov 2003 11:59:15 +0100 (MET) 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 LAA05222 for ; Sat, 8 Nov 2003 11:59:14 +0100 (MET) Received: from brazilnut.cc.columbia.edu (brazilnut.cc.columbia.edu [128.59.59.203]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hA8AxD121365 for ; Sat, 8 Nov 2003 11:59:13 +0100 (MET) Received: from tw304h3.cpmc.columbia.edu (tw304h3.cpmc.columbia.edu [156.111.84.180]) (user=ot14 mech=LOGIN bits=0) by brazilnut.cc.columbia.edu (8.12.10/8.12.10) with ESMTP id hA8Ax9gF027600 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT); Sat, 8 Nov 2003 05:59:12 -0500 (EST) From: Oleg Trott To: Dustin Sallings Subject: Re: [Caml-list] removing an item from a list efficiently Date: Sat, 8 Nov 2003 05:59:02 -0500 User-Agent: KMail/1.5.4 Cc: Caml Mailing List References: <483F0AC5-1105-11D8-AC71-000393CFE6B8@spy.net> <20031107124619.GA14374@fistandantilus.takhisis.org> <8245A4CA-11C8-11D8-95B0-000393CFE6B8@spy.net> In-Reply-To: <8245A4CA-11C8-11D8-95B0-000393CFE6B8@spy.net> MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1251" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200311080559.02325.oleg_trott@columbia.edu> X-No-Spam-Score: Local X-Scanned-By: MIMEDefang 2.35 X-Loop: caml-list@inria.fr X-Spam: no; 0.00; oleg:01 oleg:01 caml-list:01 okasaki's:01 figuring:01 prev:01 prev:01 linked:01 ocaml:01 ocaml:01 mutable:01 mutable:01 imho:01 nov:01 wrote:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Saturday 08 November 2003 03:49 am, Dustin Sallings wrote: > On Nov 7, 2003, at 4:46, Stefano Zacchiroli wrote: > > IMHO to implement an LRU policy, lists are not the best structures due > > to the O(n) limit above. You can consider standard heaps (assuming you > > have an upper bound on the number of entries) or binomial heaps (you > > can > > find an implementation in Okasaki's book). > > This is really what I was asking, whether ocaml lists could be > appropriate. > > I'm having difficulty figuring out how to implement a double linked > list, though. I want something like this: > > type 'a link = Nothing | Link of 'a t;; > > type 'a t = { > data: 'a; > mutable prev: 'a link; > mutable next: 'a link; > };; > > But, link and t don't know about each other. How does one go about > doing this kind of thing in ocaml? I've read your mind, and I think what you are trying to do is type 'a t = {data: 'a; mutable prev: 'a option; mutable next: 'a option};; or you can just do a web search for "doubly-linked list". It's out there. -- Oleg Trott ------------------- 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