[1179] in java-interest
More on collection classes
daemon@ATHENA.MIT.EDU (Bob Beck)
Fri Aug 25 15:11:01 1995
To: java-interest@java.sun.com
From: rbk@ibeam.jf.intel.com (Bob Beck)
Date: Fri, 25 Aug 95 09:16:00 Pacific Daylight Time--100
I've found that using the Enumeration interface is pretty slick (and the
interface concept in general; not quite Smalltalk's "do:" and friends with
blocks, but pretty slick anyhow). However, to make the existing collection
classes (Vector and Hashtable) and (hopefully) new Set, Bag, and others work
well together, I think some additional methods should be provided.
How about for each collection class in which it makes sense, have an
"addAll" method that takes an Enumeration, adding all the elements to the
collection. Further, have a contstructor that takes an Enumeration
interface argument, to allow easy conversion between kinds of collections.
Eg, if I wanted a set of the values in a Hashtable:
Set values = new Set(aHashtable.elements());
or, a Bag which would count the values:
Bag values = new Bag(aHashtable.elements());
If the set of standard collections could hang together as well as the
Smalltalk collections, there is a great deal of expressive power in fewer
lines of code.
--
Bob Beck rbk@ibeam.intel.com CompuServe: 71674,106
Intel Corporation (503)264-8856 AOL: RDBeck
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com