TimurMahammadov / google-collections

Automatically exported from code.google.com/p/google-collections
Apache License 2.0
0 stars 0 forks source link

filter(Collection) returning a Collection #48

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
There's no reason not to allow viewing a Collection, filtered, as another
Collection, except that size() and isEmpty() of the view become O(n).

I believe we should do this.  This would also take care of issue 45.

Original issue reported on code.google.com by kevin...@gmail.com on 30 Jan 2008 at 5:13

GoogleCodeExporter commented 9 years ago
The problem is, what class should a method like this be in?  Not Iterables; 
that's
confusing... MoreCollections?  egads.

Original comment by kevin...@gmail.com on 30 Jan 2008 at 5:13

GoogleCodeExporter commented 9 years ago
If I finish my Matcher class, this could go there. 

Matcher is an extension for Predicate, just like Ordering is to Comparator.

Original comment by limpbizkit on 31 Jan 2008 at 2:07

GoogleCodeExporter commented 9 years ago
Yeah, we sorely miss the ability to filter Lists using a predicate, something 
we were
able to do with the Jakarta collections classes. Returning a Collection based 
on a
Predicate (or Matcher), would work for us. And we wouldn't mind the O(n)-ness of
size() and isEmpty(), though I wonder why this couldn't be cached upon creating 
the
filtered Collection? In our case once we do that, we wouldn't be modifying the
underlying Collection, so it's not like things would change under our feet.

Original comment by tedyo...@gmail.com on 17 Mar 2008 at 6:55

GoogleCodeExporter commented 9 years ago
Although this is an enhancement, I believe it makes sense to get this in for 
1.0.

Original comment by kevin...@gmail.com on 27 May 2008 at 6:33

GoogleCodeExporter commented 9 years ago
I wrote Collections2.filter(Collection, Predicate) and Sets.filter(Set, 
Predicate) 
methods that create a filtered Collection or Set. They'll be in the next 
open-source
release.

Filtering a List will be more difficult, because of the additional List 
methods, but
we can do that if people want it.

Original comment by jared.l....@gmail.com on 17 Jul 2008 at 8:57