Re: Time complexity of operations on collections

2013-05-23 Thread John Jacobsen
Exactly what I was looking for, thanks!!! John On Thursday, May 23, 2013 7:06:39 PM UTC-5, Matthew wrote: > > http://www.innoq.com/blog/st/2010/04/clojure_performance_guarantees.html > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to t

Re: Time complexity of operations on collections

2013-05-23 Thread Matthew
http://www.innoq.com/blog/st/2010/04/clojure_performance_guarantees.html -- -- 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 patie

Re: Time complexity of operations on collections

2013-05-22 Thread Timothy Baldridge
No, what I'm saying is that in each persistent collection there is a method called "cons": https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentVector.java#L167 However, this is the function called by clojure.core/conj: https://github.com/clojure/clojure/blob/master/src/

Re: Time complexity of operations on collections

2013-05-22 Thread John Jacobsen
Updated draft of table in more readable form here: http://bit.ly/big-o-clojure Thanks to Timothy for corrections/additions! Will keep updating as other replies come in. -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, sen

Re: Time complexity of operations on collections

2013-05-22 Thread John Jacobsen
I am indeed confused. I have both cons and conj operations in my table. Are you saying (conj coll item) and (cons item coll) are implemented the same way under the hood? That wasn't my understanding. Can you clarify? On Wednesday, May 22, 2013 10:05:22 AM UTC-5, tbc++ wrote: > > You might al

Re: Time complexity of operations on collections

2013-05-22 Thread Timothy Baldridge
You might also want to switch "cons" to "conj". This is a super ugly part of the Java api that no one really ever sees. PersistentVector.cons is actually called by clojure.core/conj. clojure.core/cons is something else completely. When talking about how the java code performs it might be best to sp

Re: Time complexity of operations on collections

2013-05-22 Thread John Jacobsen
I should probably also have added sorted-map to the table, though the complexity for each operation is less clear to me. -- -- 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

Re: Time complexity of operations on collections

2013-05-22 Thread Timothy Baldridge
A few corrections: Lists are single linked lists, so nth on them (as well as last) is O(n). Get on lists is unsupported. Cons on a vector is O(1) since cons converts things to seqs (O(1)) before constructing the cons. Count on everything but Cons and LazySeq is O(1). For those two it's O(n) unti