Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2003-10-14 (10:44)
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 Archives:
Bug reports: FAQ:
Beginner's list: