Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] interface of sorted collections
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christian Lindig <lindig@c...>
Subject: [Caml-list] interface of sorted collections

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