> Does anybody know of an implementation for a priority queue that can
> be used for scheduling events in the future?  I would like to put a
> map associated with a timestamp into the queue and be able to pull out
> all maps at or before a given time in order.

You can do so with a combination of take-while and sort-by.

I guess it'd look like:

user> (def m (map (fn [v] {:value v :time (rand 10)}) (range 10)))
#'user/m
user> m
({:value 0, :time 0.8397557918765219} {:value 1, :time
6.4620093765233175} {:value 2, :time 4.888280209311472} {:value 3,
:time 1.8770586393181055} {:value 4, :time 8.156758802466106} {:value
5, :time 2.1849600134503886} {:value 6, :time 2.812469726965179}
{:value 7, :time 1.0214795514603459} {:value 8, :time
8.22495823217712} {:value 9, :time 7.908129555667099})
user> (take-while #(> 2 (:time %)) (sort-by :time m))
({:value 0, :time 0.8397557918765219} {:value 7, :time
1.0214795514603459} {:value 3, :time 1.8770586393181055})

This is not a priority queue implementation but it does what you need :)

U

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to