From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: tmp123 <tmp123@menta.net>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] next eleemnt in set
Date: Wed, 13 Feb 2008 09:50:57 +0100 [thread overview]
Message-ID: <47B2AF71.8050504@inria.fr> (raw)
In-Reply-To: <47B2ABE6.9090605@menta.net>
> I'm wondering which abstract type (set, map, ...) is the most useful to
> implement the following 3 methods: given a set of values, that are
> unique and ordered (it exists a "compare" function), it is necessary, in
> addition to the "add" and "remove element" methods, to have a "next"
> method. The next method takes as parameter one element of the set, and
> must return the immediatelly next element of the set, according to the
> provided compare function.
If I understand correctly your needs, you could use sets as provided
by the standard library with the following definition of "next":
module S = Set.Make(...)
let next elt s =
let (below, present, above) = S.split elt s in
assert (present);
S.min_elt above
This should run in logarithmic time, although the constant factor
might be a little high.
Hope this helps,
- Xavier Leroy
next prev parent reply other threads:[~2008-02-13 8:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-13 8:35 tmp123
2008-02-13 8:50 ` Xavier Leroy [this message]
2008-02-14 8:33 ` [Caml-list] " tmp123
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=47B2AF71.8050504@inria.fr \
--to=xavier.leroy@inria.fr \
--cc=caml-list@inria.fr \
--cc=tmp123@menta.net \
/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