commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jack, Paul" <>
Subject RE: [Commons-Avalon:collections] Buffer integration [was: code in tegration]
Date Thu, 20 Jun 2002 18:54:36 GMT
Okay, thought I'd try to prove my point by actually doing
it.  Attached is a version of FixedSizeBuffer that implements
Collection.  Also attached is a unit test for FixedSizeBuffer.
It extends our TestCollection class which is pretty thorough.
Operations are confirmed against an ArrayList to make sure that
the Buffer still contains the right elements in the right 
order, so the odds of something biting us in the butt later 
are greatly reduced.

Note that the add(Object) and remove() methods haven't changed.
(Well, okay, see the PS below).

It passes all the tests.  See?  Minimal effort, full collections
compatibility.  Essentially all I had to do was implement the
iterator.  (And I'm pretty sure VariableSizeBuffer can re-use
the same iterator, though I'd have to look more closely).

Regarding the naming issue, if it'll avoid collisions within
Jarkata, I guess I'm okay with Buffer as a name.  But maybe
FifoBuffer instead?  Or just Fifo?  Hm.  I'm just looking for
something that makes it apparent at a glance what the class
is for...


PS  I made add(Object) return a boolean to be compatible with
the Collection interface; also, I used NoSuchElementException
and IllegalStateException, but only because it reduced the
number of files I had to attach here.  I'm okay with using
the Overflow/Underflow exceptions too, I was just trying to
make my point quickly...

View raw message