Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Jan Burse Newsgroups: comp.lang.java.programmer Subject: Re: setSize ArrayList, when will it come? Date: Wed, 10 Aug 2011 09:04:20 +0200 Organization: albasani.net Lines: 28 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net EdJz/TwAYLxH1EN+owkvrk04I2RuTdA6VnXICQ5UxMVwQABbuln3zjZvHOMDFuz5pPdIOx4QzUCDWw06+wR33w== NNTP-Posting-Date: Wed, 10 Aug 2011 07:04:21 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="HYv9tAhhhmolrN1xKqNz8f/epZQX3aAtgn9vF3r+/XzxT8McC0qN0iYfrPslGX3fvIjZKM2gWXl/Q64ZLy4BiCbzcaDO9hdr3qkLrtBoP53ojTCoep0ED4JFAjlsUrof"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:5.0) Gecko/20110706 Firefox/5.0 SeaMonkey/2.2 In-Reply-To: Cancel-Lock: sha1:qPVbcOgLhXEIaq9HFf/mQWwlJqM= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6953 Joshua Cranmer schrieb: > Or you could use addAll and Collections.nCopies to implement setSize, > and use ListIterator to do reverse iteration. No you didn't get it. I need a fast specialized setSize() as argued in the bug reference. According to the collections documentation, the nCopies method does create an extra object: http://download.oracle.com/javase/1.4.2/docs/api/java/util/Collections.html#nCopies%28int,%20java.lang.Object%29 ... The newly allocated data object is tiny (it contains a single reference to the data object). ... But it is not only that this tiny object of type Collections.CopiesList will be created. For addAll call an Iterator AbstractList.Itr will be created I guess, not sure. But most likely given the abstract implementation of addAll, the abstract way it treats its argument, and in the particular situation that the argument is a CopiesList. So this is already two temporary objects on the heap. Don't have a good feeling with this. Bye