On Tue, Mar 3, 2009 at 6:22 AM, Rich Hickey <richhic...@gmail.com> wrote: > > On Mar 2, 8:40 pm, Mark Volkmann <r.mark.volkm...@gmail.com> wrote: >> On Mon, Mar 2, 2009 at 7:05 PM, Chouser <chou...@gmail.com> wrote: >> >> > On Mon, Mar 2, 2009 at 7:53 PM, Mark Volkmann <r.mark.volkm...@gmail.com> >> > wrote: >> >> >> Currently what the article says about Vectors is "They are ideal when >> >> items need to be retrieved by index, but not efficient when new items >> >> need to be added or removed quickly." It doesn't distinguish between >> >> the working in the middle or at the ends. It sounds like it should. >> >> >> Is it true that lists are more efficient than vectors when items need >> >> to be added and removed from the middle? My goal is to say something >> >> to help developers choose between using a list or a vector based on >> >> the circumstances. >> >> > Lists provide the constant time add/remove at the front, while vectors >> > provide essentially the same for the back. Seqs always walk from >> > front to back. This is often sufficient information to choose between >> > them. >> >> > Vectors provide essentially constant-time lookup by index (nth), while >> > lists provide only linear-time lookup by index. >> >> > Lists provide no convenient or efficient mechanism for "changing" a >> > value in the middle, while vectors provide essentially constant-time >> > 'assoc' for any existing position. >> >> Thanks! It sounds like I was mistaken in thinking that the >> implementation of Clojure lists was somewhat similar to >> java.util.LinkedList and the implementation of Clojure vectors was >> somewhat similar to java.util.ArrayList. I'll change the article to >> say something similar to your feedback above. >> > > Sounds like you might still be confused, as vectors do have > characteristics very much like ArrayLists, sans mutability.
Currently the "Vectors" section starts like this: "Vectors are also ordered collections of items. They are ideal when new items will be added to or removed from the back (constant-time). They are efficient (constant time) for finding (using nth) or changing (using assoc) items by index." I think it's that last sentence that hints at their similarity to ArrayLists. The beginning of the "Collections" section explains that all the Clojure collections are immutable. Do you recommend that I say something stronger about the similarity between vectors and ArrayLists or is it okay now? -- R. Mark Volkmann Object Computing, Inc. --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---