swap method
Swaps the elements at the specified positions in the specified list. (If the specified positions are equal, invoking this method leaves the list unchanged.)
Implementation
void swap(int indexA, int indexB) {
final firstOld = get(indexA);
final secondOld = set(indexB, firstOld);
set(indexA, secondOld);
}