Do you need persistence? There's a solution in java.util in Java 6. On Dec 30, 6:10 pm, Rob Lachlan <robertlach...@gmail.com> wrote: > This would work, but would require iterating over the keys, for > something like O(n) performance. I'm hoping that we can do better, > since the keys are already in an ordered collection. > > On Dec 30, 3:04 pm, Sean Devlin <francoisdev...@gmail.com> wrote: > > > > > Use a combination of take-while & key > > > (take-while (comp your-pred key) sorted-map) > > > You could also use drop while as needed. > > > I've got a blog post where I use this to solve the knapsack problem: > > >http://fulldisclojure.blogspot.com/2009/12/uses-for-takedrop-while.html > > > I've got some other stuff, too. Send me a note if you need more than > > this. > > > Sean > > > On Dec 30, 5:37 pm, Rob Lachlan <robertlach...@gmail.com> wrote: > > > > About a year and a half ago, there was some discussion about having a > > > function that would enable some kind of bounded search on a sorted > > > map: > > > >http://groups.google.com/group/clojure/browse_thread/thread/949cae6c0... > > > > Does this exist, currently? I haven't looked at the gory details of > > > PersistentTreeMap, so I don't know how difficult this would be to do. > > > Intuitively though, since we have the keys are in a sorted tree, I > > > thought that it would be possible to have a bounded search in > > > something like O(log n). > > > > Rob > > > > p.s. I asked a related question on stackoverflow: > > > >http://stackoverflow.com/questions/1981859/finding-keys-closest-to-a-...
-- 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