Good discussion. Here are some thoughts:
* The utility class David referenced provides methods to convert an
Iterator to a Collection (by internally iterating through all of the
elements and building a new collection to return). There are some limited
situations in which this is useful, but it doesn't appear to me that the
examples given by Pavel and David would be helped by this utility class.
* David's examples, I think, deal with a different situation where a single
class maintains two (or more) distinct collections. In this case, the
iterator() method has to choose one of them, so the for/in loop is only
going to work on one of the classes. Consider a class Bars which maintains
internal Collections of both Foos and Bars. You could still, of course,
use for/in in both cases and write:
for (Foo foo : bars.getFoos()) {
:
}
and
for (Bar bar : bars) {
:
}
* Pavel's example (DailyAnalysis) is a situation in which a method (get)
returns an Object, which in some cases can be a List and in other cases can
be a non-Collection. Thus, there's no way to iterate(), since you're not
guaranteed of always getting an instance that is iterable. That may have
been a poor design decision; we can revisit it in Version 8.
Cheers,
Philip
--On April 16, 2007 11:56:00 PM -1000 Pavel Senin <[EMAIL PROTECTED]> wrote:
Hi:
I don't know what is non-standard in this context, but there are some
collections that are still (WHY?)
not parameterized, for example in the DailyAnalysis we have method
"public Object get(int index)",
which returns a List in my case that it is not possible to iterate with
"for:each" loop.
On 4/16/07, Aaron Kagawa <[EMAIL PROTECTED]> wrote:
Just curious what is an example of the non-standard iterator that exists
in Hackystat?
thanks, Aaron
At 11:29 PM 4/16/2007, David Nickles wrote:
I think we need something like these methods in our system to facilitate
the for-each loops on some of the non-standard iterators that exist
within the system.
http://dlt-dev.ncsa.uiuc.edu/javadoc/t2/org/tupeloproject/util/Iterators.
html
--
David J. Nickles
Information and Computer Sciences
University of Hawaii at Manoa
1680 East West Rd. POST 312A
Honolulu, HI 96822
voice: [Image] [Image] [Image] [Image] [Image] [Image] [Image]
[Image] [Image] [Image] [Image] [Image] (808)956-3497 [Image] fax:
(808)956-3548
eMail | Web | vCard
--
--~--~---------~--~----~------------~-------~--~----~
Best regards, Pavel Senin, mailto: [EMAIL PROTECTED]
ICQ: 11788606. +18087289645