LinkedList facelift
Rémi Forax
forax at univ-mlv.fr
Wed Nov 4 14:18:07 UTC 2009
Le 03/11/2009 20:32, Martin Buchholz a écrit :
>
>
> On Tue, Nov 3, 2009 at 01:06, Rémi Forax <forax at univ-mlv.fr
> <mailto:forax at univ-mlv.fr>> wrote:
>
> Hi Martin,
> Your patch can break backward compat.
>
> add(E) now delegates to a public method (an overridable one)
> (addLast). So If I have a class that inherits from LinkedList
> and overrides addLast() the current semantics of add(E) is not
> altered,
> with your patch, add(E) semantics is also changed.
>
> I think the code of addLast() should be in a private method and
> addLast() and add(E) delegate to it.
>
>
> Rémi, thanks for the review. I've added you as a reviewer.
>
> I agree. Although relying on such implementation details is a bad idea,
> and implementations are very likely to differ, and the existing LinkedList
> is a hodge-podge of differing styles of methods calling other public
> methods, we should strive to maintain this kind of compatibility if
> the price is not too high.
>
> Also, I did some cosmetic touchups, and commented out the asserts.
>
> Webrev regenerated.
>
> Martin
>
Good for me if addFirst() calls linkFirst() and
addLast() calls linkLast().
Rémi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20091104/8e947609/attachment.html>
More information about the core-libs-dev
mailing list