Java Array Swap swap3(String[] a, int x, int y, int z)

Here you can find the source of swap3(String[] a, int x, int y, int z)

Description

Auxiliary method for sorting lexicographically the strings.

License

Open Source License

Parameter

Parameter Description
a represents the array with the strings for sorting.
x position of the first string.
y position of the second string.
z position of the third string.

Declaration

private static void swap3(String[] a, int x, int y, int z) 

Method Source Code

//package com.java2s;
/**// www.j  a  va  2 s  .c  o m
 * Copyright (c) 1997, 2015 by ProSyst Software GmbH and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */

public class Main {
    /**
     * Auxiliary method for sorting lexicographically the strings. Shuffling strings on positions x, y and z, as the
     * string
     * at the position x, goes to the position z, the string at the position y, goes to the position x and the string
     * at the position z, goes to the position y.
     *
     * @param a represents the array with the strings for sorting.
     * @param x position of the first string.
     * @param y position of the second string.
     * @param z position of the third string.
     */
    private static void swap3(String[] a, int x, int y, int z) {
        String t = a[x];
        a[x] = a[y];
        a[y] = a[z];
        a[z] = t;
    }
}

Related

  1. swap(T[] data, int a, int b)
  2. swap(T[] elements, int i, int j)
  3. swap(T[] ts, int i, int j)
  4. swap2(double v[], int v2[], int i, int j)
  5. swap2Bytes(byte[] bytes, int offset)
  6. swapAll(final Object[] array)
  7. swapAndPrint(int[] arr, int m, int n)
  8. swapArray(int[] v, int i, int j)
  9. swapArrayStr(String[] arr)