caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Christian Lindig <lindig@cs.uni-sb.de>
To: Caml Mailing List <caml-list@inria.fr>
Subject: [Caml-list] interface of sorted collections
Date: Tue, 14 Oct 2003 12:39:55 +0200	[thread overview]
Message-ID: <20031014103955.GF20130@st> (raw)


I have noted that in sorted collections like the Map and Set modules
(but also in SML/NJ's ORD_SET and ORD_MAP) it is impossible to find the
previous or next element for a given element. This seems strange, given
that the keys in these collections are sorted.

In my particular application I like to store (nested) intervals in a
map, sorted by their starting points. Given a point in an interval, I'd
like to obtain it from a sorted collection. This requires either a
find_less_equal function, that returns the key for an element if it
exists or its predecessor, or a prev_key function, that returns a key's
predecessor such that I can use the regular find afterwards.

Is there a way to implement this in OCaml without making a copy of the
Map module?

-- Christian

-------------------
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


             reply	other threads:[~2003-10-14 10:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-14 10:39 Christian Lindig [this message]
2003-10-15  7:23 ` Florian Hars
2003-10-15  9:56   ` Damien Doligez

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=20031014103955.GF20130@st \
    --to=lindig@cs.uni-sb.de \
    --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;
as well as URLs for NNTP newsgroup(s).