Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Priority queues, reloaded
Date: Thu, 30 Jun 2011 20:03:09 +0200	[thread overview]
Message-ID: <20110630180309.GA11388@yquem.inria.fr> (raw)
In-Reply-To: <848371343.3424870.1309454037170.JavaMail.root@zmbs3.inria.fr>

Hi,

Not sure what I am going to say is relevant or not, but in my software
GeneWeb, I implemented a priority queue a very simple way, and where
insertion and get are in constant time.

But... my problem is very specific: my priorities are always integers
between zero and a relatively small integer number (namely 100 or 150)
and will very not likely become larger (and if it does, the queue can
be easily dynamically extended).

In that situation, my priority queue is just an array of that size (let's
say 150) of lists of items.

Insertion queue item =
  let p = item.priority in
  queue.(p) := item :: queue.(p)

Get queue :=
  let p = first_index_with_not_empty_list queue in
  let r = List.hd queue.(p) in
  queue.(p) := List.tl queue.(p);
  r

-- 
Daniel de Rauglaudre
http://pauillac.inria.fr/~ddr/

       reply	other threads:[~2011-06-30 18:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <848371343.3424870.1309454037170.JavaMail.root@zmbs3.inria.fr>
2011-06-30 18:03 ` Daniel de Rauglaudre [this message]
2011-07-09 18:45 james woodyatt
     [not found] ` <14B0DF03-EF83-4568-AB34-6B51BCE4B574@recoil.org>
2011-07-09 18:56   ` james woodyatt
     [not found] <fa.V8myB/rA6OKILQg+GW40f8c1BGo@ifi.uio.no>
2011-07-02 12:24 ` Radu Grigore
2011-07-02 19:05   ` Andrew
2011-07-02 22:42   ` Radu Grigore
2011-07-10 17:55     ` Jon Harrop
     [not found] <sfid-j-20110630-131704-+2.76-1@multi.osbf.lua>
2011-06-30 17:13 ` Andrew
2011-06-30 17:26   ` Gabriel Scherer
2011-06-30 18:14     ` Jean-Christophe Filliâtre
2011-06-30 18:36     ` Jean-Christophe Filliâtre
2011-07-09  9:02       ` Jon Harrop
2011-07-09 19:22         ` Jean-Christophe Filliâtre
2011-07-10 18:04           ` Jon Harrop
2011-06-30 19:13     ` Andrew
2011-06-30 22:17     ` Wojciech Meyer
2011-07-02  1:49   ` Norman Ramsey
2011-07-09  9:05   ` Jon Harrop

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110630180309.GA11388@yquem.inria.fr \
    --to=daniel.de_rauglaudre@inria.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox