Peter Firmstone wrote:
Patricia Shanahan wrote:
On 7/21/2010 5:25 PM, Peter Firmstone wrote:
Instead of Task passing an Iterable<Task>, it could pass an
Enumerator<Task>, which is inherently immutable. One more comment
inline.
I assume you mean Enumeration<Task>? I prefer Iterable<Task> because
it allows for the enhanced for loop:
Yep.
public Task runAfter(Iterable<Task> candidates){
for(Task t: candidates){
if(this has to wait for t){
return t;
}
}
return null;
}
Given the number of TaskManager callers, I think there is value in
keeping their code as clean and simple as possible.
Ok, didn't think of that, still using the old for loop.
I think the subtle issue that Peter was getting at though, is that Iterator has
the "remove()" method which perhaps should not be a published behavior, since it
implies an API that is not currently in the design of the system. I'm not that
bothered by this in an internal API, but in some cases, you have to be careful,
and perhaps pass a copy, as in
new ArrayList<Task>( ... ).interator()
just to make sure that your original collection is not compromised by other
software.
Gregg Wonderly