commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@btopenworld.com>
Subject [collections] Number of elements matching a Predicate
Date Sun, 24 Nov 2002 21:28:02 GMT
http://issues.apache.org/bugzilla/show_bug.cgi?id=9422

Proposal is to add a method (or four) to return true if all/none/one or more
of the elements match the predicate.

Anyone got any views on this? I'm minded to reject it as not adding enough
to the API, eg.

    /**
     * Returns <code>true</code> if all the elements in the input collection
     * match the specified predicate.
     *
     * @param inputCollection  the collection to get the input from, may not
be null
     * @param predicate  the predicate to use, may be null
     * @return true if all elements match the predicate
     * @throws NullPointerException if the input collection is null
     */
    public static boolean matchesAll(Collection inputCollection, Predicate
predicate) {
        return select(inputCollection, predicate).size() ==
inputCollection.size();
    }

ie. the code isn't very much, but is the method signature clearer?

Stephen


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message