Should Iterators.partition use an ImmutableList internally?

Skip to first unread message

Sean Parsons

Dec 23, 2009, 4:29:16 PM12/23/09
to Google Collections Library - developer list
Looking at Iterators.partition there are these two lines:
List<T> list = Collections.unmodifiableList(
(List<T>) Arrays.asList(array));
return (pad || count == size) ? list : Platform.subList(list,
0, count);

Would it make sense for these to use ImmutableList.of instead? Or
potentially even using the builder in a wider sense for the padding,
but that's more than a one line type change.

This would also eliminate the dependency of this method on Platform,
which seems like a bonus.

Kevin Bourrillion

Dec 23, 2009, 4:37:58 PM12/23/09
to Sean Parsons, Google Collections Library - developer list
Problem is: partition() supports null elements (and in fact uses them for padding); ImmutableList doesn't.

The Platform dependency is going away anyway, since GWT 2.0 supports List.subList() natively.

Google Collections Library - developer list

To unsubscribe, send email to:

Kevin Bourrillion @ Google
internal:  http://go/javalibraries

Reply all
Reply to author
0 new messages