/** * Returns a list that contains all the elements of the input from startIndex (included) to endIndex (included). */ public static <T> List<T> subListInclusive(int startIndex, int endIndex, List<T> input) { List<T> output = new ArrayList<>(); int outputLenth = subLengthInclusive(startIndex, endIndex, input); int i = startIndex; while (output.size() != outputLenth) output.add(getWrap(i++, input)); return output; }
/** * Removes all the elements from the list from startIndex (included) to endIndex (included). */ public static int removeAllInclusive(int startIndex, int endIndex, List<?> list) { int numberOfElementsToRemove = subLengthInclusive(startIndex, endIndex, list); for (int count = 0; count < numberOfElementsToRemove; count++) { startIndex = wrap(startIndex, list); list.remove(startIndex); } return numberOfElementsToRemove; }