I'd say it's something to evaluate on a case-by-case basis. But I
think there's another question hidden inside your first question,
which is, "Should I let the types used internally in my operations
drive the return value of the public API?" And I think the answer
there is "Absolutely not."
You know, it's funny. I wondered whether I was going to mention the
typical "go for readability and optimize later" argument, and then
chose not to.
I agree to disagree. Maybe you and I write very different code, and
with that I stick to my first sentence: evaluate this on a case by
case basis. Still, don't let the internal data structure take control
of your design -- you're in control.
Actually, the library includes the following methods:
Collections2.filter()
Collections2.transform()
Sets.filter()
Lists.transform()
There isn't a Sets.transform(), since the function could map two distinct elements into the same value, violating the Set contract.
A Lists.filter() method would return a list that lacks random access, since it would have to find the nth element that satisfies the filter. It seems better to omit a method that could inadvertently cause poor performance.
The library includes the filter and transform methods that make sense, except for SortedSet/Map methods that nobody has asked for.
Jared