From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=AWL,MAILTO_TO_SPAM_ADDR autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 9E6A7BC6B for ; Sat, 4 Aug 2007 14:58:25 +0200 (CEST) Received: from einhorn.in-berlin.de (einhorn.in-berlin.de [192.109.42.8]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l74CwO61000708 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sat, 4 Aug 2007 14:58:25 +0200 X-Envelope-From: oliver@first.in-berlin.de X-Envelope-To: Received: from einhorn.in-berlin.de (localhost [127.0.0.1]) by einhorn.in-berlin.de (8.13.6/8.13.6/Debian-1) with ESMTP id l74CwOmp021097 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Sat, 4 Aug 2007 14:58:24 +0200 Received: (from www-data@localhost) by einhorn.in-berlin.de (8.13.6/8.13.6/Submit) id l74CwOrx021095 for caml-list@yquem.inria.fr; Sat, 4 Aug 2007 14:58:24 +0200 X-Authentication-Warning: einhorn.in-berlin.de: www-data set sender to oliver@first.in-berlin.de using -f Received: from dslb-088-073-079-147.pools.arcor-ip.net (dslb-088-073-079-147.pools.arcor-ip.net [88.73.79.147]) by webmail.in-berlin.de (IMP) with HTTP for ; Sat, 4 Aug 2007 14:58:24 +0200 Message-ID: <1186232304.46b477f03d21c@webmail.in-berlin.de> Date: Sat, 4 Aug 2007 14:58:24 +0200 From: Oliver Bandel To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Sorted list References: <46B4485B.7040406@menta.net> In-Reply-To: <46B4485B.7040406@menta.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.6 X-Scanned-By: MIMEDefang_at_IN-Berlin_e.V. on 192.109.42.8 X-Miltered: at concorde with ID 46B477F0.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; bandel:01 in-berlin:01 elt:01 sugestion:01 ocaml:01 ocaml:01 val:01 oliver:01 oliver:01 caml-list:01 pair:01 int:01 int:01 modules:02 caml:02 Hello, do you have no real name? Zitat von tmp123@menta.net: [...] > > Of the standard modules, the most similar seems "set", because allows > insertion and has the funcion "min_elt". However, the problem is, if two > timers have the same time, addition of the second one removes the first. > > Please, has someone any sugestion? > [...] You can make the type of the Set a pair, with the time and the timerid (if it is created in ascending order) as it's elements. Then you can compare the time and the id. Ocaml makes this for you easy: ======================================================== oliver@siouxsie2:~$ ocaml Objective Caml version 3.09.2 # let pl = [("12:17:22", 20); ("13:44:23", 3); ("12:17:22", 2); ("12:17:22",1); ("12:17:22",12)];; val pl : (string * int) list = [("12:17:22", 20); ("13:44:23", 3); ("12:17:22", 2); ("12:17:22", 1); ("12:17:22", 12)] # List.sort compare pl;; - : (string * int) list = [("12:17:22", 1); ("12:17:22", 2); ("12:17:22", 12); ("12:17:22", 20); ("13:44:23", 3)] # ======================================================== So, a simple compare would also work for your Set. Ciao,