Chuck
I share Jari's concerns that Map already has 3 ways of making itself appear
to be a collection, keySet(), entrySet() and values(). I'm not sure why a
Collection wrapper is required.
James
----- Original Message -----
From: "Jari Worsley" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 30, 2001 9:01 AM
Subject: Re: [SUBMIT] [Collections] MapCollection adapter class
> Charles Burdick wrote:
> >
> > In the past, I've found it frustrating that the Map interface does not
> > implement Collection. So here's an adapter to make a Map look like a
> > Collection. Some of the methods really operate on the keySet, but on
> > the whole it should suit many needs.
>
> Couple of questions
>
> - if you're using a map, you're using a map because you want key-value
> pairs stored for some application specific reason. You may want a
> collection for reading from the map at some point, in which case why not
> just use the values() method that returns a Collection of the values.
>
> other methods aren't clear how they should work when wrapped in just a
> Collection interface, like:
> - iterator() - Collection returns the elements in the collection. So do
> you return the keys? or the values? I see you have chosen to return the
> keySet iterator in your implementation - this is the opposite of what I
> would expect.
>
> -same with the remove and toArray methods - you're working with the keys
> not the values, which seems counterintuitive to me.
>
> If i want to work with the keys of a Map, then I'll use the keySet
> directly.
> If i want to work with the values, then MapCollection doesn't really
> help me, as I can just use the values() method on Map to return a
> Collection.
>
> I guess I don't really see the point in this.
>
> Jari
>
>
> --
> Jari Worsley
> Senior Programmer
> Hyperlink Interactive Ltd
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com