Closed GoogleCodeExporter closed 9 years ago
Hey koppernickus,
This was already discussed in the google-collections issues / group, but your
question is legitimate since there is no mention of it in the guava project's
issues / group ;)
Guava does not provide such a method, because the filtered List view would have
very poor performance.
They could have Lists.filter() return a filtered *copy* instead, but:
- it would be counter-intuitive, since the similarly named
Collections2.filter() and Iterables.filter() both returns *views* instead of
copies
- there is the problem of the choice of the List implementation to return:
should we return an ArrayList? an ImmutableList? a LinkedList?
For these reasons, it is preferable to let the developer do the copy himself:
ImmutableList.copyOf(Iterables.filter(*))
Lists.newArrayList(Iterables.filter(*))
...
If you really want the syntactical sugar, and you know which implementation
type you want to use in your project, you could create a static utility method
that hides this boilerplate.
More info:
http://code.google.com/p/google-collections/issues/detail?id=7#c2
http://code.google.com/p/google-collections/issues/detail?id=98#c1
http://groups.google.com/group/google-collections-users/browse_thread/thread/2f0
120513488977e
http://groups.google.com/group/google-collections-users/browse_thread/thread/5ad
e208a52ee3973
http://groups.google.com/group/google-collections-users/msg/fac903c3a542d77f
Original comment by nev...@gmail.com
on 30 Dec 2010 at 11:45
Woops, just saw the related thread in the Google Group. It seems like you
already knew all of this...
Anyway, I'll link it here, since it's related:
http://groups.google.com/group/guava-discuss/browse_thread/thread/278dd6a99214d9
1a
Original comment by nev...@gmail.com
on 31 Dec 2010 at 12:15
Seems like the question has been sufficiently answered.
Original comment by boppenh...@google.com
on 31 Dec 2010 at 4:54
Thanks for explanation, but what I really meant was explaining it on Wiki.
Most of the users don't read forum, they just go to Wiki pages. If you put
link to this thread in this page
http://code.google.com/p/guava-libraries/wiki/IdeaGraveyard I would be happy
:-)
Original comment by kopperni...@gmail.com
on 31 Dec 2010 at 9:57
Great idea, its done.
Original comment by boppenh...@google.com
on 31 Dec 2010 at 6:47
Issue 848 has been merged into this issue.
Original comment by wasserman.louis
on 28 Dec 2011 at 5:55
Issue 958 has been merged into this issue.
Original comment by wasserman.louis
on 4 Apr 2012 at 2:04
Issue 959 has been merged into this issue.
Original comment by cgdec...@gmail.com
on 4 Apr 2012 at 3:20
This issue has been migrated to GitHub.
It can be found at https://github.com/google/guava/issues/<id>
Original comment by cgdecker@google.com
on 1 Nov 2014 at 4:15
Original comment by cgdecker@google.com
on 3 Nov 2014 at 9:09
Original issue reported on code.google.com by
kopperni...@gmail.com
on 27 Dec 2010 at 7:51