On Sat, Jan 30, 2010 at 7:31 PM, Rowdy Rednose <rowdy.redn...@gmx.net> wrote:
> I want to have it in O(1). That's why I use a tree map in the first
> place.
>
> On Jan 31, 9:15 am, Sean Devlin <francoisdev...@gmail.com> wrote:
>> If you can live with an O(n) operation, take/drop-with will do the
>> job.
>>
>> Sean
>>
>> On Jan 30, 6:59 pm, Rowdy Rednose <rowdy.redn...@gmx.net> wrote:
>>
>> > How would I do something like these 3 TreeMap operations with
>> > clojure's sorted-map?
>>
>> > The goal is to narrow down a map to include only keys with a given
>> > prefix.

Items in a sorted map cannot be found, added, or removed in O(1).
Those operations are O(log2 n) on sorted maps and sets.

(first m) will return the lowest-sorted item in a sorted map,
O(log2 n).

(dissoc (key (first m))) will return a map with that first item
removed, O(log2 n),

The subseq function can be used for efficiently walking various
sorted slices of a sorted map.

Hope that helps,
--Chouser
http://joyofclojure.com/

-- 
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