I have an ArrayList
to be filtered, and various Guava Predicate
s to filter it with. This list will have only 50-100 elements.
I was planning on
This may be an occasion when using a loop is simplest.
List list =
Predicate[] predicates =
Map> removed =
new LinkedHashMap>();
for(Iterator iter=list.iterator();list.hasNext();) {
MyType mt = iter.next();
for(Predicate pred: predicates)
if(pred.apply(mt)) {
List mts = removed.get(pred);
if(mts == null)
removed.put(pred, mts = new ArrayList());
mts.add(mt);
iter.remove();
break;
}
}