Last active
August 29, 2015 14:22
-
-
Save PierreBtz/09ecb01545d6c0bccf80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <T> void trim(List<T> list, int newSize) { | |
Preconditions.checkArgument(newSize >= 0, "Cannot trim the provided list to a negative size"); | |
int size = list.size(); | |
list.subList(Math.min(newSize, size), size).clear(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment