Browse thread
Sorted list
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2007-08-04 (09:35) |
From: | tmp123@m... |
Subject: | Sorted list |
Hello, In order to implement a timers subsystem, I need a module with the following values: *) add_timer : time -> ( unit -> unit ) -> timerid, for public usage, where "add_timer t f" means execute "f" at time "t". The result is an identifier who allows cancelation of the timer. *) cancel_timer: timerid -> unit for public usage, cancel a previously added timer *) peek_minimum_timer : unit -> ( time, unit -> unit ) for internal usage, get the timer with minimum time. Returns the time and the related function. *) remove_minimum_timer : ?? -> unit for internal usage, remove the timer with the minimum time. It will be called after execute a timer. Thus, in a generic sense, what I need is a "sorted list", with easy insertion of elements, and peek/pop of the head (minimum). Of the standard modules, the most similar seems "set", because allows insertion and has the funcion "min_elt". However, the problem is, if two timers have the same time, addition of the second one removes the first. Please, has someone any sugestion? Thanks a lot.