* next eleemnt in set
@ 2008-02-13 8:35 tmp123
2008-02-13 8:50 ` [Caml-list] " Xavier Leroy
0 siblings, 1 reply; 3+ messages in thread
From: tmp123 @ 2008-02-13 8:35 UTC (permalink / raw)
To: caml-list
Hello,
Thanks for your time.
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.
Please, have someone any suggestion?
Thanks again.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] next eleemnt in set
2008-02-13 8:35 next eleemnt in set tmp123
@ 2008-02-13 8:50 ` Xavier Leroy
2008-02-14 8:33 ` tmp123
0 siblings, 1 reply; 3+ messages in thread
From: Xavier Leroy @ 2008-02-13 8:50 UTC (permalink / raw)
To: tmp123; +Cc: Caml List
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] next eleemnt in set
2008-02-13 8:50 ` [Caml-list] " Xavier Leroy
@ 2008-02-14 8:33 ` tmp123
0 siblings, 0 replies; 3+ messages in thread
From: tmp123 @ 2008-02-14 8:33 UTC (permalink / raw)
To: caml-list
[-- Attachment #1: Type: text/html, Size: 1587 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-02-14 8:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-13 8:35 next eleemnt in set tmp123
2008-02-13 8:50 ` [Caml-list] " Xavier Leroy
2008-02-14 8:33 ` tmp123
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox