Re: Optimizaton for finding the next key in a sorted-map

2020-05-26 Thread Harmon Nine
Thanks very much for your responses. :) 'subseq' looks like it will do what's needed. -- Harmon On Monday, May 25, 2020 at 4:47:58 PM UTC-5, Harmon Nine wrote: > > Is there an optimization for sorted-maps that, when you have a given key > in the map, you can get the next key in O(log n) time?

Re: Optimizaton for finding the next key in a sorted-map

2020-05-25 Thread Matthew Downey
Don't forget about subseq and rsubseq, the technology behind [the world's smallest time series database]( https://www.dotkam.com/2015/12/02/time-series-database-in-one-line-of-clojure/) ;) On Monday, May 25, 2020 at 4:47:58 PM UTC-5, Harmon Nine wrote: > > Is there an optimization for

Re: Optimizaton for finding the next key in a sorted-map

2020-05-25 Thread Carlo Zancanaro
Hey Harmon, On Tue, May 26 2020, Harmon Nine wrote: > Does such an optimization exist? If not, is there an means of getting the > next-key in a sorted-map given a current-key that is better than O(n)? I just had a look at clojure.core and found that subseq operates on a sorted collection.

Re: Optimizaton for finding the next key in a sorted-map

2020-05-25 Thread 'Alex Miller' via Clojure
Hi, there is no such optimization and that's not really feasible in the sorted-map impl. However there are other sorted map data structures like https://github.com/clojure/data.avl which have facilities in this area. On Monday, May 25, 2020 at 4:47:58 PM UTC-5, Harmon Nine wrote: > > Is there

Optimizaton for finding the next key in a sorted-map

2020-05-25 Thread Harmon Nine
Is there an optimization for sorted-maps that, when you have a given key in the map, you can get the next key in O(log n) time? Given "compare" is the boolean function on which the sorted-map is based, the following code will get the next-key given a current-key: (defn get-next-key [my-map