Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.utanet.at!newscore.univie.ac.at!aconews-feed.univie.ac.at!aconews.univie.ac.at!not-for-mail Newsgroups: comp.lang.java.programmer From: Andreas Leitgeb Subject: Re: setSize ArrayList, when will it come? References: <9aetckFmvmU1@mid.individual.net> <9aftbqFa9kU1@mid.individual.net> Reply-To: avl@logic.at User-Agent: slrn/pre0.9.9-111 (Linux) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: Date: 11 Aug 2011 00:23:07 GMT Lines: 28 NNTP-Posting-Host: gamma.logic.tuwien.ac.at X-Trace: 1313022187 tunews.univie.ac.at 71616 128.130.175.3 X-Complaints-To: abuse@tuwien.ac.at Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7003 Jan Burse wrote: > But when there are 100 entries their indexes might span the > range of 1000. But it is very important that the access to > the elements is O(1). In *that* case, I'd use a plain array, sized to say 2048 and just index into it. > Just assume you have an existing application with Vector > that happily uses setSize(). So what do you do? I'd try to find out, whether the current .size() is relevant to the business logic. If not, then most of the repeated setSize()ing maybe was just a waste of cpu-time&energy, anyway. If it is, then I might keep it in a separate variable or field, and keep the array or ArrayList at some sufficiently large size. If it is, and the collection itself gets passed to external interfaces that care about the size ... or similar misfortunes, then I'd give up and stay with Vector. (Yes, if ArrayList had .setSize(), then this particular leaf of the decision tree would fare better.) Based on that you mentioned "no money (no time) for a rewrite", I might just as well give up on conversion, anyway and stay with Vector. If that is too slow, then *they* should spend some money (or time) on making it faster.