Jaggregate, my Java-5-only Smalltalk-ish collections library, has collections that support the Java collections' notions of addAll()
, removeAll()
, and retainAll()
. For usability's sake, there are three overloads of each:
void addAll( jaggregate.Collection<? extends E> others ); void addAll( E... others ); void addAll( java.lang.Iterable<? extends E> others ); boolean removeAll( jaggregate.Collection<? extends E> others ); boolean removeAll( E... others ); boolean removeAll( java.lang.Iterable<? extends E> others ); boolean retainAll( jaggregate.Collection<? extends E> others ); boolean retainAll( E... others ); boolean retainAll( java.lang.Iterable<? extends E> others );
The "varargs" forms allow specification of a real array argument, or of a variable-length argument list:
OrderedCollection<Integer> primes = new OrderedCollection<Integer>(); primes.addAll( new Integer[] { 2, 3, 5, 7 } ); primes.addAll( 11, 13, 17, 19 );
I made a mistake in the specification of the "varargs" overloads. As written, they allow a zero-length argument list. At best, addAll()
just looks goofy:
primes.addAll(); // add all what? to where?
And removeAll()
and retainAll()
get downright confusing:
primes.removeAll(); // removes nothing primes.retainAll(); // removes everything
So, I decided to change the "varargs" overloads to:
void addAll( E newElement, E... moreNewElements ); boolean removeAll( E oldElement, E... moreOldElements ); boolean retainAll( E keeper, E... moreKeepers );
Now, zero-arg calls to the *All()
methods won't compile (hopefully there weren't any out there to begin with), and if you really mean to hand the methods zero args, you can still do so with an array type rather than a varargs list.
Paul,
I'd be interested in collaborating on your spiffy collections library, if you're interested.
I think Ruby is doing the right thing by following the Smalltalk lead in having many, more precise ways of doing similar things than in trying to have a pseudo-complete orthogonal operation set as the JDK tries to do.
Cheers,
--binkley
Posted by: B. K. Oxley (binkley) | January 20, 2006 at 09:21
binkley, your help is most welcome. i tried dropping you a mail--the yahoo mail bounced, and didn't get a response on the rice addr. anyway, gimme a holler, and i can help you get started.
--p
Posted by: Pholser | January 31, 2006 at 13:12
http://moreaboutmen.com/chart/europe/
Posted by: Gxzkicd | December 13, 2007 at 17:05