commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@btopenworld.com>
Subject Re: [collections] KeySetMap?
Date Mon, 03 May 2004 23:19:40 GMT
This sounds more like a map that validates whether its keys are in a
predetermined Set. That way, the map would operate as normal, size is size
of mappings, cannot add to keySet but can remove etc.

The main idea is to separate the validation Set from the actual keySet. This
is now really easy to achieve as I checked in the
AbstractInputCheckedMapDecorator today, which allows validation to be easily
performed (see checkPutKey). Or use AbstractHashedMap if you don't want to
decorate (see addMapping).

Stephen

----- Original Message -----
From: "Michael Heuer" <heuermh@acm.org>
> I need an implementation of Map that uses a predefined set of keys as its
> keySet.  Changes made to the set of keys should be reflected in the map's
> keySet but not the other way around, e.g. map.keySet() should be
> unmodifiable.
>
> I've written something using a wrapped map but I'm having trouble
> specifying all of the desired behavior.  For instance, if the size of
> the keySet is > 0 but no mappings exist, what is the size of the map?
> Would the entrySet view contain entries containing each key mapped to
> null?  What should map.remove(key) do?  etc.
>
> Any comments are appreciated.
>
>    michael
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message