/----------------------------------------------------------------------------
orMap:
boolean orMap(Traversal tr, ISelect choice){
return orMapAcc(tr, false, ISelect choice);
}
Method Header: boolean orMapAcc(Traversal tr, boolean acc, ISelect choice)
BASE-VALUE: false
UPDATE: boolean update(T t, boolean acc, ISelect choice){
return (choice.select(t)) || acc;
}
---------------------------------------------------------------------------*/
/** RECURSIVE VERSION
* Determine if any data item generated by the given traversal
* satisfies the given ISelect predicate.
*/
public <T> boolean orMap(Traversal<T> tr,
ISelect<T> choice){
return orMapAcc(tr, false, choice);
}
/** RECURSIVE VERSION --- accumulator based helper.
* Determine if any data item generated by the given traversal
* satisfies the given ISelect predicate.
*/
public <T> boolean orMapAcc(Traversal<T> tr,
boolean acc,
ISelect<T> choice){
if (tr.isEmpty())
return acc;
else
return orMapAcc(tr.getRest(),
updateOrMap(tr.getFirst(), acc, choice),
choice);
}
/** A helper to produce the updated value of the accumulator
* @param <T> the type of data in this data set
* @param t the instance of the data to be used in the update
* @param acc the current value of the accumulator
* @param choice the given ISelect predicate.
* @return the updated value of the accumulator.
*/
protected <T> boolean updateOrMap(T t,
boolean acc,
ISelect<T> choice){
return (choice.select(t)) || acc;
}