From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id E7408BC8A for ; Sun, 30 Jan 2005 10:51:15 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j0U9pFoV018740 for ; Sun, 30 Jan 2005 10:51:15 +0100 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 KAA13374 for ; Sun, 30 Jan 2005 10:51:15 +0100 (MET) Received: from smtp1.wanadoo.fr (smtp1.wanadoo.fr [193.252.22.30]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j0U9pERu018735 for ; Sun, 30 Jan 2005 10:51:15 +0100 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf0107.wanadoo.fr (SMTP Server) with ESMTP id D73C9A00018A for ; Sun, 30 Jan 2005 10:51:14 +0100 (CET) Received: from nono (ARouen-106-1-9-53.w80-14.abo.wanadoo.fr [80.14.114.53]) by mwinf0107.wanadoo.fr (SMTP Server) with SMTP id 8D96DA000188 for ; Sun, 30 Jan 2005 10:51:14 +0100 (CET) X-ME-UUID: 20050130095114580.8D96DA000188@mwinf0107.wanadoo.fr Message-ID: <001901c506b1$7d89fb60$0100a8c0@mshome.net> From: =?iso-8859-1?Q?Fr=E9d=E9ric_Gava?= To: Subject: Fw: [Caml-list] Missing a function Date: Sun, 30 Jan 2005 10:53:02 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Miltered: at concorde with ID 41FCAE13.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 41FCAE12.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; gava:01 gava:01 caml-list:01 stdlib:01 functor:01 functor:01 ord:01 struct:01 ord:01 sig:01 val:01 expansive:01 ....:98 ...:98 int:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: Hi, > > > Another option is to build on top of the stdlib Map functor another > > functor that keeps track of the cardinal of a map : > > > > module CMap = functor (Ord : Map.OrderedType) -> > > (struct > > module M = Map.Make (Ord) > > > > type key = M.key > > type 'a t = int * 'a M.t > > > > let cardinal = fst > > > > let empty = 0, M.empty > > > > let add k v (n, m) = (n + 1, M.add k v m) > > > > let find k (_, m) = M.find k m > > > > .... > > : sig > > include Map.S > > val cardinal : 'a t -> int > > end) > > Hum. To remove an element, you have to test is its exists or not before decrease n. It could be to much cost expansive...no ? Regards, Frédéric Gava