Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Joshua Cranmer Newsgroups: comp.lang.java.programmer Subject: Re: setSize ArrayList, when will it come? Date: Tue, 09 Aug 2011 20:36:38 -0500 Organization: A noiseless patient Spider Lines: 19 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 10 Aug 2011 01:36:44 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="B3q1fNdvNsCxx/IZ4idKGA"; logging-data="28598"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19KdVhbWnzI/vhUSGdLY+tyqymiY6eh2Rs=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0 In-Reply-To: Cancel-Lock: sha1:F2Rb6hBzOGzxf0GpZ31KU2uhKXk= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6943 On 8/9/2011 5:31 PM, Jan Burse wrote: > And the AbstractList could implement abstractly the inefficient > setSize() that would use remove() and add(), when Random access is > present via index, or otherwise maybe with a backward iterator. > Backward iterator is also missing btw. And then concrete classes > could provide more efficient implementations if necessary. Or you could use addAll and Collections.nCopies to implement setSize, and use ListIterator to do reverse iteration. Notice that ArrayList does not sport a sort method--it's on Collections.sort. Just because the method is not on the list itself does not mean it's not implemented. Implementing it on the class implies that anyone who implements the same interface has to reimplement it or forward it to the same implementation all over again. -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth