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.

Rich

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

Reply via email to