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: Tue, 09 Aug 2011 04:16:05 +0200 Organization: albasani.net Lines: 41 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net h2hrMXYEYf/Nx+WuVK23ep2BKdz+0Kin2fXhtY74Etlbl7cCeUnaZxAR8oTTCw5XKc+8pBjNZF0VlRdYbMqqbA== NNTP-Posting-Date: Tue, 9 Aug 2011 02:16:06 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="hcIVWkuHZRho1T4I3j6afsnBKuQLjWx3fL3EyGchMohy+tZsTWysdNUC4zaugf2FqJQAYwA9jsXL+rPAs1VFQ921H19VWqkAOatvEIRZNDmQUWIWF0kgWXCex38v8KXE"; 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:la+K+a61CnVBHR2AbtgtCvmaszE= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6891 Eric Sosman schrieb: > Perhaps if you'd explain your use case in more detail > someone will have a suggestion you may find helpful. I have only referted to the meta use case in my post. The software refactoring use case, is replacing a synchronized Vector by an unsychronized ArrayList in regions where no synchronization is necessary. This meta use case could even have IDE support. For example IntelliJ has IDE support for the detection of unnessary use of StringBuffer and suggests the class StringBuilder. Similarly an IDE could suggest ArrayList in certain places where Vector is used. But it will not succeeded in such cases where I did use setSize on my Vector. I actually do use setSize for a kind of sparse Vector. Sparse in the sense that my Vector will have a couple of holes represented by null value elements. Which is eventually abuse of the term "sparse", but the use case is there. The missing thought in the reponse is the design goal of ArrayList. They are explicitly advertised in the class comment as unsynchronized version of Vector. It is brainless not to honor such a design goal in a response. On the other hand it is very clever to have the possibility of turning initial design goals into requests for enhancement. Imagine the following situation: You go into a restaurant and order pizza, you get your pizza without cheese, you ask the waiter what is wrong, and the waiter says, oh this cannot be changed, cheese has to be ordered separately. Brainless are we, who accept this. Best Regards