List of utility methods to do List Swap
List | swap(List Method to swap elements at two indexes if (list != null && list.size() > 2 && maxIndex > minIndex) { List<T> updatedList = new ArrayList<>(); T elementAtMinIndex = list.get(minIndex); T elementAtMaxIndex = list.get(maxIndex); for (int i = 0; i < list.size(); i++) { if (i != minIndex && i != maxIndex) { updatedList.add(i, list.get(i)); } else if (i == minIndex) { ... |
void | swapElements(List swap Elements int index1 = list.indexOf(element1); int index2 = list.indexOf(element2); if (index1 == -1 || index1 == -1) { return; Collections.swap(list, index1, index2); |
void | swapItems(final List Swaps 2 items if (from == to) return; if (!hasElements(data)) return; if (from < 0 || from >= data.size()) { throw new IllegalArgumentException("'from' must be within 0 to n-1"); if (to < 0 || to >= data.size()) { ... |
void | swapListElements(List list, int idx1, int idx2) swap List Elements Object tmp = list.get(idx1); list.set(idx1, list.get(idx2)); list.set(idx2, tmp); |