commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@eurobell.co.uk>
Subject Re: [Collections][SUBMIT] WeakHashSet
Date Mon, 29 Apr 2002 22:16:05 GMT
From: Jack, Paul <pjack@sfaf.org>
> > 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.

A cunning plan...

> 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);
>     }

The input and output I'm happy with. Its the queries I wasn't so sure about.
I guess that they are a kind of input... And in the String interning example
that was suggested the queries would need to be transformed. Hmm, I'm
talking myself into this ;-)

> > 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.

Great, I'll try to manage these sometime in this week (without the Proxy*
classes).

Stephen



--
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