commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Berin Loritsch" <>
Subject RE: [Commons-Avalon:collections] code integration
Date Thu, 20 Jun 2002 17:06:10 GMT
> From: Jack, Paul [] 
> > It looks like most of collections was already copied over
> > some time ago
> > (just over a year ago).  The only things missing are the 
> > Buffer classes
> > and the BucketMap.
> I actually have a few issues with the Buffer interface...
> 1.  Shouldn't it be named Queue?  I mean, isn't that what it 
> is?  A data structure in which elements are added to the end 
> and removed from the beginning?  I only care because the 
> buffer class name collides with java.nio.Buffer.

Essentially that is what it is doing.  I do differentiate between
that and a full fledged Queue as I have that defined in my Event
package.  The core Event package does not depend on anything
that isn't already set to be donated to Commons.

> 2.  I also have this problem with BinaryHeap, and was going
> to submit a patch one day.  Shouldn't Buffer extend 
> Collection? The add and remove operations could still be 
> optimized; the other Collection operations would probably be 
> slow but still possible to implement.  Having them implement 
> Collection would make them more interoperable with more or 
> less everything, like the CollectionUtils algorithms.

No!  Buffer should not extend Collection.  You should not be
able to add or remove items from the middle of a Buffer.  It
is precisely that.  A buffer.

In fact the Buffer takes advantage of that fact.  The main
issue is with the Iterator.remove(), and the fact that the
elements as they come off the buffer should be removed.

The Iterator is particularly problematic.  Do you remove the
items from the buffer after they have been read by the Iterator?

They have a special purpose, and I think by *forcing* them
to be Collections they will lose all their benefits.

As to the BinaryHeap, I don't know about it.  I didn't write
it so I can't say what problem it was trying to solve.

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

View raw message