public static <T> Set<T> grep(Set<T> self, Object filter) {
        return (Set<T>) grep((Collection<T>) self, filter);
    }
public static < T > Set < T > grep ( Set < T > self , Object filter ) { return ( Set < T > ) grep ( ( Collection < T > ) self , filter ) ; }
Iterates over the collection of items and returns each item that matches
the given filter - calling the <code>{@link #isCase(java.lang.Object, java.lang.Object)}</code>
method used by switch statements.  This method can be used with different
kinds of filters like regular expressions, classes, ranges etc.
Example:
<pre class="groovyTestCase">
def set = ['a', 'b', 'aa', 'bc', 3, 4.5] as Set
assert set.grep( ~/a+/ )  == ['a', 'aa'] as Set
assert set.grep( ~/../ )  == ['aa', 'bc'] as Set
assert set.grep( Number ) == [ 3, 4.5 ] as Set
assert set.grep{ it.toString().size() == 1 } == [ 'a', 'b', 3 ] as Set
</pre>

@param self   a Set
@param filter the filter to perform on each element of the collection (using the {@link #isCase(java.lang.Object, java.lang.Object)} method)
@return a Set of objects which match the filter
@since 2.4.0