Should Iterators.partition use an ImmutableList internally?

6 views
Skip to first unread message

Sean Parsons

unread,
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

unread,
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
http://groups.google.com/group/google-collections-dev?hl=en

To unsubscribe, send email to:
google-collection...@googlegroups.com



--
Kevin Bourrillion @ Google
internal:  http://go/javalibraries
external: guava-libraries.googlecode.com

Reply all
Reply to author
Forward
0 new messages