List of utility methods to do List Truncate
L | setSize(L list, int newsize) Truncates 'list' or adds null elements to its end int n = list.size(); if (newsize > n) { list.addAll(java.util.Collections.<T>nCopies(newsize - n, null)); } else if (newsize < n) { list.subList(newsize, n).clear(); return list; |
void | setSize(List> list, int size) set Size if (size < list.size()) { list.subList(size, list.size()).clear(); } else { while (size > list.size()) { list.add(null); |
List | trunc(List as, int length) trunc if (length < as.size()) remove(as, length, as.size()); return as; |
void | truncate(final List> list, final int newSize) Truncate a list to a size by removing elements at its end, if necessary. final int currentSize = list.size(); for (int i = currentSize - 1; i >= newSize; i--) { list.remove(i); |
List | truncate(final List truncate if (limit > items.size()) { return new ArrayList<>(items); final List<T> truncated = new ArrayList<>(limit); for (final T item : items) { truncated.add(item); if (truncated.size() == limit) { break; ... |
void | truncate(List> list, int length) truncate while (list.size() > length) {
list.remove(list.size() - 1);
|
void | truncateEnd(List> list, int numElements) Truncates the given list by removing elements from the end such that numElements entries remain. if (list.size() > numElements) {
list.subList(numElements, list.size()).clear();
|
List | truncateList(final List Truncates the given list to have the given maximum size. final int numToDisplay = Math.min(full.size(), maxSize); return full.subList(0, numToDisplay); |
void | truncateList(int offset, int count, List truncate List List<T> retVal = new ArrayList<T>(originalList); if (offset > 0) { if (offset < retVal.size()) { retVal.subList(0, offset).clear(); if (count > 0 && count < retVal.size()) { retVal.subList(count, retVal.size()).clear(); ... |
ArrayList | truncateList(List extends T> input, int maxSize) truncate List if (input == null) { input = new ArrayList<T>(); int endIndex = Math.min(input.size(), maxSize); ArrayList<T> result = new ArrayList<T>(endIndex); for (int i = 0; i < endIndex; i++) { result.add(input.get(i)); return result; |