Opened 13 years ago
Last modified 13 years ago
#337 closed enhancement
Make ERF implement Iterable<ProbEqkSource> and ProbEqkSource implement Iterable<ProbEqkRupture> — at Initial Version
Reported by: | Kevin Milner | Owned by: | Kevin Milner |
---|---|---|---|
Priority: | major | Milestone: | OpenSHA 1.3 |
Component: | sha | Version: | |
Keywords: | ERF | Cc: |
Description
This is just an idea, so feel free to disagree/discuss below. Personally, I find the following code to be very long winded:
for (int sourceID=0; sourceID<erf.getNumSources(); sourceID++) { ProbEqkSource source = erf.getSource(sourceID); for (int rupID=0; rupID<source.getNumRuptures(); sourceID++) { ProbEqkRupture rup = source.getRupture(rupID); // do work on rup } }
For many cases (where knowing the source/rup IDs is not important), this could be replaced with the following:
for (ProbEqkSource source : erf) { for (ProbEqkRupture rup : erf) { // do work on rup } }
In order to do this, ERF would have to implement Iterable<ProbEqkSource?>, and ProbEqkSource? would then need to implement Iterable<ProbEqkRupture?>. This would add one method to each:
public Iterator<T> iterator();
What do you think? I don't foresee any adverse impact of adding this.
Note: See
TracTickets for help on using
tickets.