Looking at the description, CopyOnWriteArrayList does not provide
predicate-based filtering.
I was thinking something like:
interface BooleanPredicate<E> {
public boolean check(E o);
}
class CollectionOps {
List copyMatchingPredicate(List list, BooleanPredicate<E> predicate) {
for all objects in the list
if (predicate.check(object)) {
copy object to resulting list
}
}
Then one could do this:
List<Overlay> sourceList = ....;
List<Overlay> resultList =
CollectionOps.copyMatchingPredicate(sourceList, new
BooleanPredicate<Overlay>() {
@Override
public boolean check(Overlay overlay) {
return ! (overlay instanceof UserOverlay);
}
});
-- Kostya
15.09.2010 21:40, Kumar Bibek пишет:
There's a class that does this.
CopyOnWriteArrayList
-Kumar Bibek
http://techdroid.kbeanie.com
On Sep 15, 9:56 pm, Kostya Vasilyev<[email protected]> wrote:
> I'm actually surprised that Java Collections doesn't have a copy
> methods that takes a predicate.
>
> C++ STL has this: remove_copy_if
>
> -- Kostya
--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en