You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Chris Shayan (JIRA)" <ji...@apache.org> on 2008/11/08 13:12:46 UTC

[jira] Commented: (COLLECTIONS-306) Use Predicate in subtract

    [ https://issues.apache.org/jira/browse/COLLECTIONS-306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12645976#action_12645976 ] 

Chris Shayan commented on COLLECTIONS-306:
------------------------------------------

I've developed the method myself please test it by other developers, the code is:

    public static Collection subtract(final Collection a, final Collection b, Predicate p) {  
        ArrayList list = new ArrayList(a);  
        for (int i = 0; i < list.size(); i++) {  
            Object o = list.get(i);  
            if(!p.evaluate(o)) {  
                list.remove(i);  
            }  
        }  
        return list;  
    }  

> Use Predicate in subtract
> -------------------------
>
>                 Key: COLLECTIONS-306
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-306
>             Project: Commons Collections
>          Issue Type: New Feature
>          Components: Collection
>         Environment: all OSs
>            Reporter: Chris Shayan
>   Original Estimate: 0.75h
>  Remaining Estimate: 0.75h
>
> It is good idea to use Predicate in subtract method, I've developed myself the mentioned method and now I am testing it. I mean we should have following methods:
> The one already exist is:
> public static Collection subtract(Collection a, Collection b)
> I offer to have one more which is:
> public static Collection subtract(Collection a, Collection b, Predicate predicate)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.