commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jack, Paul" <pj...@sfaf.org>
Subject RE: [Collections][SUBMIT] WeakHashSet
Date Mon, 29 Apr 2002 21:47:46 GMT
> I'm not sure a two transformer approach is all thats needed. Collections
> have three basic types of method:
> - input (add/set)
> - query (indexOf, contains, equals, remove)
> - output (get, toArray)
> The Predicate/Transform proposal covers only the input group at the
moment.
>
> A 'two transformer' approach would cover the output group of methods (but
> would require another 7 classes to do it). This is perfectly possible, but
> naming would be interesting :-)

Well, we could eliminate the need for 1-transformer implementations by
providing an "identity" transform, that doesn't actually alter the object.

And it seems that the "query" group of functions would just use the
"input" transform...here's what the code looks like in my head:

    public boolean contains(Object value) {
        value = inputTransformer.transform(value);
        return wrapped.contains(value);
    }

    public Object get(int index) {
        Object result = wrapped.get(index);
        return outputTransformer.transform(result);
    }

    public Object set(int index, Object value) {
        value = inputTransformer.transform(value);
        Object result = wrapped.set(index, value);
        return outputTransformer.transform(result);
    }


> I have looked at the ProxyMap. It is suitable for use by the Predicate and
> Transform classes as it provides protected access to the map, but no
public
> method to access it. Thus ProxyList and ProxySet would also be useful.
> However, that would still only cover 3 of the 7 collections!
 
It's true, we'd be adding six public classes to the API...

> At the moment I'm pausing on the implementation of the predicate/transform
> classes until things clear.

Well the Predicate implementations, at any rate, appear uncontroversial, and
would be extremely useful.

-Paul

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


Mime
View raw message