Java Array Swap swapArrayValues(int i1, int i2, int[] indices)

Here you can find the source of swapArrayValues(int i1, int i2, int[] indices)

Description

Swaps the two indexed values in the indices array.

License

Open Source License

Parameter

Parameter Description
i1 First index
i2 Second index
indices Array of indices to swap

Declaration

private static void swapArrayValues(int i1, int i2, int[] indices) 

Method Source Code

//package com.java2s;
/*/*  w  w  w  .j  av a  2  s. c o  m*/
 * File:                CollectionUtil.java
 * Authors:             Justin Basilico
 * Company:             Sandia National Laboratories
 * Project:             Cognitive Foundry
 *
 * Copyright March 25, 2008, Sandia Corporation.
 * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
 * license for use of this work by or on behalf of the U.S. Government. Export
 * of this program may require a license from the United States Government.
 * See CopyrightHistory.txt for complete details.
 *
 */

public class Main {
    /**
     * Swaps the two indexed values in the indices array.
     *
     * @param i1 First index
     * @param i2 Second index
     * @param indices Array of indices to swap
     */
    private static void swapArrayValues(int i1, int i2, int[] indices) {
        int temp = indices[i1];
        indices[i1] = indices[i2];
        indices[i2] = temp;
    }
}

Related

  1. swap3(String[] a, int x, int y, int z)
  2. swapAll(final Object[] array)
  3. swapAndPrint(int[] arr, int m, int n)
  4. swapArray(int[] v, int i, int j)
  5. swapArrayStr(String[] arr)
  6. swapBlocks(byte[] array, int fromA, int toA, int fromB, int toB)
  7. swapByteArray(byte[] source)
  8. swapByteOrder(byte[] a)
  9. swapByteOrder32(byte[] data, int ofs, int len)