Re: Status of bounded search on sorted-map?

2009-12-30 Thread Rob Lachlan
Thanks very much, that makes a lot of sense. I looked through the java code for PersistentTreeMap, and indeed those methods are private. I think that I'll be happy with subseq and rsubseq. Being a noob, it hadn't occured to me that I could do that. On Dec 30, 8:04 pm, Timothy Pratley wrote: > 2

Re: Status of bounded search on sorted-map?

2009-12-30 Thread Timothy Pratley
2009/12/31 Rob Lachlan : > 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 > Does this exist, currently?  I haven't looked at the gory details of subseq and rsubseq provide efficient bounded searching. I don

Re: Status of bounded search on sorted-map?

2009-12-30 Thread Rob Lachlan
Thanks for the pointer. I had a feeling that java world had something like this, but I'd much prefer to be able to do this from clojure. Appreciate the info, though. On Dec 30, 3:14 pm, Sean Devlin wrote: > Do you need persistence?  There's a solution in java.util in Java 6. > > On Dec 30, 6:10 

Re: Status of bounded search on sorted-map?

2009-12-30 Thread Sean Devlin
Do you need persistence? There's a solution in java.util in Java 6. On Dec 30, 6:10 pm, Rob Lachlan 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

Re: Status of bounded search on sorted-map?

2009-12-30 Thread Rob Lachlan
I should have said: since the keys are already in a tree. If they were in a linked list, I'd expect to have to iterate over most of the list. On Dec 30, 3:10 pm, Rob Lachlan wrote: > This would work, but would require iterating over the keys, for > something like O(n) performance.  I'm hoping th

Re: Status of bounded search on sorted-map?

2009-12-30 Thread Rob Lachlan
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 wrote: > Use a combination of take-while & key > > (take-while (comp your-pred k

Re: Status of bounded search on sorted-map?

2009-12-30 Thread Sean Devlin
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, to

Status of bounded search on sorted-map?

2009-12-30 Thread Rob Lachlan
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/949cae6c085d3d39/65b4082085c19a60?q= Does this exist, currently? I haven't looked at the gory