commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Waldhoff, Rodney" <>
Subject RE: [collections] Primitive collections
Date Mon, 14 Oct 2002 23:35:35 GMT
> I suspect there's a design that would allow consistent names to be
> used (add(), get()), but also to be able to treat something as a
> real Collection or Map. Something Proxy-ish or Adapter-ish
> comes to mind; at least, some form of composition.

Sounds reasonable.

> (actually, if you're using addInt() it's not
> clear to me how you could use the class as a real Collection or Map
> anyway, since you can't use the substitution principle because
> you've extended the interface). 

The substitution is meant to go the other way--classes or methods that expect Collection or
Map (or in the only concrete case here, List), can use the primitive version directly.  I
can take an IntArrayList and pass it off to Collections.binarySearch or Collections.shuffle
for example.

A wrapping (Adapter) approach, something like: 
 Collections.shuffle(new ListToPrimitiveListAdapter(mylist));
is a viable alternative, in fact IMO that's preferable.

Wouldn't be difficult to implement right now if we're willing postpone the collections release
by a day or two.

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message