Hi, On Aug 9, 8:06 am, gary ng <garyng2...@gmail.com> wrote:
> Assuming vector is implemented in some form of array(well it seems to > have the characteristic of an array where accessing any element would > be O(1)), appending one element can be O(1) if there are space > reserved for some extra items but if that action is repeated till the > slack is filled up, some form of re-shuffling is needed. It doesn't use arrays underneath (not in the "one big array" sense), but a tree. So copying of array contents is limited to arrays sizes of 32 elements, which still counts as O(1). So it is in general faster than using cons + reverse, which is O(n) and doesn't work with infinite input. See here for more info: http://blog.higher-order.net/2009/02/01/understanding-clojures-persistentvector-implementation/ Accessing an element in a vector is actually O(log32 n), not O(1). Sincerely Meikel -- 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