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

Re: DxHashMap can't clone when empty



Hi,
  Your code will do exactly the same thing as mine.  clone(DxMap) is not
overridden in DxHashMap, so clone(DxMap) and super.clone(DxMap) are exactly
the same method.

  Now, if you mean that you should get your new object by calling
super.clone() instead of new, then in general I agree with you.  I just
went for the quick fix, when I should have written:

	public Object clone() {
		DxHashMap newMap = super.clone();
		newMap.ht = ht.clone();
		return newMap;
	}

  If you are going to tell someone someting is basic, it pays to get it
right yourself :)

later,

\x/ill        :-}

--On Mon, Feb 21, 2000 12:05 PM +0100 Hans Verschoor and Jennie Kohsiek
<hanjen@casema.net> wrote:

> Yes, but your problem is really over if you:
> 
> return super.clone(newMap);
> 
> This is virtual method basics !
> 
> ----- Original Message -----
> From: Falko Braeutigam <falko@softwarebuero.de>
> To: Ozone DB Mailing List <ozone-users@ozone-db.org>
> Sent: Tuesday, February 15, 2000 4:29 PM
> Subject: Re: DxHashMap can't clone when empty
> 
> 
>> On Tue, 15 Feb 2000, William Uther wrote:
>> > Hi all,
>> > 
>> > The title says it all really.  On a 1.1 VM DxHashMap.clone() ends up
>> > calling new Hashtable(count()) where count() is the number of elements
> in
>> > the map.  However, when count() is 0 this is a bad thing.  The
>> > following version of clone() works:
>> > 
>> >     public Object clone() {
>> >     int newSize = count();
>> >     if (newSize < 10)
>> >     newSize = 10;
>> >         DxMap newMap = new DxHashMap (newSize);
>> >         return clone (newMap);
>> >         }
>> Thanks for the fix! On my Alpha, jdk1.2 the 0 size for the hashtable is
>> no problem. :|
> 
>