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
>
> 15.09.2010 20:34, Pedro Teixeira пишет:
>
>
>
> > Worked like a charm Kostya :DDDD
>
> > Thank you !!! I've used the iterator but didn't thought about
> > ''instanceof'', it was erasing everything. Now it's perfect.
>
> > Thank you very much :D
>
> > Pedro
>
> > On Sep 15, 2010, at 5:24 PM, Kostya Vasilyev wrote:
>
> >> Pedro,
>
> >> I believe list.remove(object item) removes the first element has is
> >> equal() to the one passed in.
>
> >> To remove items by some other criteria (such as actual class), you've
> >> got to iterate the list.
>
> >> Note that removing elements while iterating has to be done by calling
> >> remove() on the iterator. Calling remove() on the collection itself
> >> while iterating is not supported, and throws an exception that says
> >> as much.
>
> >> List<Overlay> list = mapView.getOverlays();
>
> >> for (Iterator<Overlay> ite = list.iterator(); ite.hasNext(); )
> >> {
> >> Overlay ov = ite.next();
> >> if (ov instanceof UserOverlay) {
> >> ite.remove();
> >> }
> >> }
>
> >> Hope this helps.
>
> >> -- Kostya
>
> >> 15.09.2010 20:06, Pedro Teixeira пишет:
> >>> Hi,
>
> >>> I have an overlay list which I retrieve it like this:
>
> >>> List<Overlay>  overlays = mapView.getOverlays();
>
> >>> So in this list I have elements of the type userOverlay and
> >>> picOverlay..
> >>> How can I do to erase ALL occurences of userOverlay but leave all the
> >>> others?
> >>> I've been playing around with the List methods but I can't make it
> >>> work, I've tried:
>
> >>>           while(overlays.contains(userOverlay)==true){
> >>>                   overlays.remove(userOverlay);
> >>>           }
>
> >>> Which made sense to me.. but it doesn't work..
> >>> any suggestions?
>
> >> --
> >> 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
>
> > Pedro Teixeira
>
> >www.pedroteixeira.org
>
> --
> 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

Reply via email to