On Sat, 8 May 2010, Igor Stasenko wrote:

On 7 May 2010 23:47, Lukas Renggli <reng...@gmail.com> wrote:
He had the idea that it would be nice to be able to add any object to a 
LinkedList, instead of just Link subclasses. (IIRC, 'like you can in Ruby' ;))

So we added ValueLink as the common pattern for "A link with an object in it", 
which is now the default if you add an object which itself is not a link.

Makes it much more convenient to actually use a LinkedList, ref. f.ex. the 
Stack implementation.

LinkedList is used internally by the process scheduler to handle
processes, I don't think that it is ment to be used as a public
collection class. For probably all applications it is slower and uses
more memory than an OrderedCollection.

+1.
OrderedCollection's addLast/removeFirst/removeLast, is enough to use
them as lists.

No. These methods make it good enough (or at least they should, but we know that they don't) to use OrderedCollections as stacks, queues or double-ended queues (which are the common cases), but adding an element before or after another takes O(n) time, compared to lists' O(1). Though this feature can only be used if we allow the users to reference the links directly, otherwise lists have no advantage.


About performance, i am little concerned.
Linked lists is good , that is costs you a constant time for each new
element you adding.
While for OrderedCollections it vary depending on container state. In
most cases, it costs you as little as for linked lists, but when
contained is not big enough to hold all elements - then it has to grow
and consuming a lot more time comparing to adding a previous element.

That would be true if there was no GC. And as Ralph pointed out, the amortized cost of adding/removing elements to/from the ends of an OrderedCollection is O(1) (or at least it should be, but it's not).


Levente


Lukas

--
Lukas Renggli
www.lukas-renggli.ch

_______________________________________________
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project




--
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to