java.util.LinkedList clear() improvement

Guy Korland gkorland at gmail.com
Thu Aug 27 12:41:17 UTC 2009


First, LinkedList by definition is not thread safe so there's no need
to care about concurrency.
Second this is what modCount is all about, preventing an iterator to
keep on working.
Guy

On Thu, Aug 27, 2009 at 3:35 PM, Carsten Otto
<otto at informatik.rwth-aachen.de> wrote:
>
> On Thu, Aug 27, 2009 at 03:31:13PM +0300, Guy Korland wrote:
> > It seems like linkedList.clear() can be easily fixed to O(1) instead of O(n).
>
> With your solution one would be possible to continue working (traversing)
> on an empty (read: emptied) list. I don't think this is desired.
>
> Best regards,
> --
> Carsten Otto           otto at informatik.rwth-aachen.de
> LuFG Informatik 2      http://verify.rwth-aachen.de/otto/
> RWTH Aachen            phone: +49 241 80-21211
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iEYEARECAAYFAkqWfYMACgkQjUF4jpCSQBQfnwCeIPkTnCT6XgmYUKBJFV/fhHQl
> vk0AoOh74vYjVStadJovFMgYuNnH7iQp
> =CWub
> -----END PGP SIGNATURE-----
>



--
Guy Korland



More information about the core-libs-dev mailing list