[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [really patch] Re: HashMap putAll/putAllInternal bug

From: Stuart Ballard
Subject: Re: [really patch] Re: HashMap putAll/putAllInternal bug
Date: Mon, 13 Oct 2003 12:09:48 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3.1) Gecko/20030527 Debian/1.3.1-2

Stephen Crawley wrote:
The corollary is that if you can't provide a valid (and sufficiently
efficient for your purposes) implementation for an abstract method in
AbstractMap, then you should NOT be extending AbstractMap.  Rather you
should be implementing the Map interface from scratch.

It doesn't matter whether I inherit from AbstractMap or not - I am, in fact, but it's irrelevant to the discussion at hand, because the code that's causing a problem is in HashMap, not AbstractMap, and it applies when a Map of my type is passed to putAll() on a HashMap.

The problem is that, while I could implement the size() method correctly on my Map type, it would be very slow, and hence all the algorithms which "optimize" by using size() instead of hasNext()* are pessimizations instead. And performance is important for my usage.


* Does anyone actually have a single example of a case where hasNext() is slow? Seems to me that it can never be significantly slower than size() because if it were, it could be implemented as "return counter < size()".

Stuart Ballard, Senior Web Developer
FASTNET - Web Solutions
(215) 283-2300, ext. 126

reply via email to

[Prev in Thread] Current Thread [Next in Thread]