<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/10/4e4b1aa34c29e58e6db93315ea915984"
  from="Christian Lindig &lt;lindig@c...&gt;"
  author="Christian Lindig"
  date="2003-10-14T10:44:52"
  subject="[Caml-list] interface of sorted collections"
  prev="2003/10/0ffe577457a6e7656e19a496908ae8c2"
  next="2003/10/9fbf3af3346026a5d782ec2c1884b8e3"
  next-in-thread="2003/10/ec2bb18a7972f5b5cac7e6be93ed017e"
  prev-thread="2003/10/90ca861a25ed8e5d1d82dbb9d0fe2021"
  next-thread="2003/10/bb6652d3ee0174ff91bc648fa5125d46"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] interface of sorted collections">
<msg 
  url="2003/10/4e4b1aa34c29e58e6db93315ea915984"
  from="Christian Lindig &lt;lindig@c...&gt;"
  author="Christian Lindig"
  date="2003-10-14T10:44:52"
  subject="[Caml-list] interface of sorted collections">
<msg 
  url="2003/10/ec2bb18a7972f5b5cac7e6be93ed017e"
  from="Florian Hars &lt;hars@b...&gt;"
  author="Florian Hars"
  date="2003-10-15T07:23:35"
  subject="Re: [Caml-list] interface of sorted collections">
<msg 
  url="2003/10/57c7a1c5ff0f45f78d981bdff9210697"
  from="Damien Doligez &lt;damien.doligez@i...&gt;"
  author="Damien Doligez"
  date="2003-10-15T09:55:24"
  subject="Re: [Caml-list] interface of sorted collections">
</msg>
</msg>
</msg>
</thread>

<contents>

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

</contents>

</message>

