Swap two elements of a short array at the specified positions

@param shortArray array that will have two of its values swapped.
@param index1 one of the indexes of the array.
@param index2 other index of the array.
504933
public static void swap(short[] shortArray, int index1, int index2) {
        TrivialSwap.swap(shortArray, index1, shortArray, index2);
    }
867042
private static void swap(Object[] arr, int i, int j) {
		Object tmp = arr[i];
		arr[i] = arr[j];
		arr[j] = tmp;
	}
444663
private void swap(int i, int j) {
        int t = pq[i];
        pq[i] = pq[j];
        pq[j] = t;
        qp[pq[i]] = i;
        qp[pq[j]] = j;
    }
861461
private static void quickSort1(int off, int len, IntComparator comp, Swapper swapper) {
	// Insertion sort on smallest arrays
	if (len < SMALL) {
		for (int i=off; i<len+off; i++)
		for (int j=i; j>off && (comp.compare(j-1,j)>0); j--) {
		    swapper.swap(j, j-1);
		}
		return;
	}

	// Choose a partition element, v
	int m = off + len/2;       // Small arrays, middle element
	if (len > SMALL) {
		int l = off;
		int n = off + len - 1;
		if (len > MEDIUM) {        // Big arrays, pseudomedian of 9
			int s = len/8;
			l = med3(l,     l+s, l+2*s, comp);
			m = med3(m-s,   m,   m+s, comp);
			n = med3(n-2*s, n-s, n, comp);
		}
		m = med3(l, m, n, comp); // Mid-size, med of 3
	}
	//long v = x[m];
	
	// Establish Invariant: v* (<v)* (>v)* v*
	int a = off, b = a, c = off + len - 1, d = c;
	while(true) {
		int comparison;
		while (b <= c && ((comparison=comp.compare(b,m))<=0)) {
			if (comparison == 0) {
				if (a==m) m = b; // moving target; DELTA to JDK !!!
				else if (b==m) m = a; // moving target; DELTA to JDK !!!
			    swapper.swap(a++, b);
			}
			b++;
		}
		while (c >= b && ((comparison=comp.compare(c,m))>=0)) {
			if (comparison == 0) {
				if (c==m) m = d; // moving target; DELTA to JDK !!!
				else if (d==m) m = c; // moving target; DELTA to JDK !!!
			    swapper.swap(c, d--);
			}
			c--;
		}
		if (b > c) break;
		if (b==m) m = d; // moving target; DELTA to JDK !!!
		else if (c==m) m = c; // moving target; DELTA to JDK !!!
		swapper.swap(b++, c--);
	}

	// Swap partition elements back to middle
	int s, n = off + len;
	s = java.lang.Math.min(a-off, b-a  );  vecswap(swapper, off, b-s, s);
	s = java.lang.Math.min(d-c,   n-d-1);  vecswap(swapper, b,   n-s, s);

	// Recursively sort non-partition-elements
	if ((s = b-a) > 1) 
		quickSort1(off, s, comp, swapper);
	if ((s = d-c) > 1) 
		quickSort1(n-s, s, comp, swapper);
}
948721
public static void quickSort(
			  String[]        vector,
			  int             startIndex,
			  int             endIndex
		 )
	{
		 int     i       = startIndex;
		 int     j       = endIndex;
		 String  pivot   = vector[(i + j) / 2];
		 do {
			  while (i < endIndex && pivot.compareTo(vector[i]) > 0) {
					++i;
			  }
			  while (j > startIndex && pivot.compareTo(vector[j]) < 0) {
					--j;
			  }
			  if (i < j) {
					String  temp    = vector[i];
					vector[i]       = vector[j];
					vector[j]       = temp;
			  }
			  if (i <= j) {
					++i;
					--j;
			  }
		 } while (i <= j);
		 if (startIndex < j) {
			  quickSort(vector, startIndex, j);
		 }
		 if (i < endIndex) {
			  quickSort(vector, i, endIndex);
		 }
	}
493018
private static void insertionSortReverse(double[] keys, int[] vals, final int start, final int end) {
    // Classic insertion sort.
    for(int i = start + 1; i < end; i++) {
      for(int j = i; j > start; j--) {
        if(keys[j] <= keys[j - 1]) {
          break;
        }
        swap(keys, vals, j, j - 1);
      }
    }
  }
1002839
public static void shuffle(int[] intArray) {
		int swapPlace = -1;

		for(int i = 0; i < intArray.length; i++) {
			swapPlace = (int) (Math.random() * (intArray.length - 1 ));
			XORSwap.swap(intArray, i, swapPlace);
		}
	}
590116
static <T> void crossover(
		final MSeq<T> that,
		final MSeq<T> other,
		final int[] indexes
	) {

		for (int i = 0; i < indexes.length - 1; i += 2) {
			final int start = indexes[i];
			final int end = indexes[i + 1];
			that.swap(start, end, other, start);
		}
		if (indexes.length%2 == 1) {
			final int index = indexes[indexes.length - 1];
			that.swap(index, min(that.length(), other.length()), other, index);
		}
	}
714194
public static void shuffle(long[] longArray) {
		int swapPlace = -1;

		for(int i = 0; i < longArray.length; i++) {
			swapPlace = (int) (Math.random() * (longArray.length - 1 ));
			XORSwap.swap(longArray, i, swapPlace);
		}
	}
860642
public static void swap(float arr[], int i, int j) {
        float a = arr[i];
        arr[i] = arr[j];
        arr[j] = a;
    }
352217
public static void swap(long[] longArray, int index1, int index2) {
        TrivialSwap.swap(longArray, index1, longArray, index2);
    }
57223
private void swap(int n, int m) {
		int eM = elements[m];
		int eN = elements[n];
		elements[m] = eN;
		elements[n] = eM;
		positions[eM] = n;
		positions[eN] = m;
	}
76315
function _swapWorkingSetListIndexes(paneId, index1, index2) {
        var pane = _getPane(paneId);

        pane.swapViewListIndexes(index1, index2);
        exports.trigger("workingSetSort", pane.id);
        exports.trigger("_workingSetDisableAutoSort", pane.id);
    }
669288
public static void swap(int[] x, int i, int j) {
        int s = x[i];
        x[i] = x[j];
        x[j] = s;
    }
424074
public static void swap(Array array, int left, int right) throws ExpressionException {
	int len = array.size();

	if (len == 0) throw new ExpressionException("array is empty");
	if (left < 1 || left > len) throw new ExpressionException("invalid index [" + left + "]", "valid indexes are from 1 to " + len);
	if (right < 1 || right > len) throw new ExpressionException("invalid index [" + right + "]", "valid indexes are from 1 to " + len);

	try {
	    Object leftValue = array.get(left, null);
	    Object rightValue = array.get(right, null);

	    array.setE(left, rightValue);
	    array.setE(right, leftValue);
	}
	catch (PageException e) {
	    throw new ExpressionException("can't swap values of array", e.getMessage());
	}

    }
34471
public void swapRows(int r1, int r2, Object tmp)
    {
        int col = columns();
        System.arraycopy(array, col * r1, tmp, 0, col);
        System.arraycopy(array, col * r2, array, col * r1, col);
        System.arraycopy(tmp, 0, array, col * r2, col);
    }
668267
public static int[] swap(int[] array, int index1, int index2) {
		if (isEmpty(array)) {
			throw new IllegalArgumentException("Number array must not empty !");
		}
		int tmp = array[index1];
		array[index1] = array[index2];
		array[index2] = tmp;
		return array;
	}