Java Array Swap swap(Object[] array, int a, int b)

Here you can find the source of swap(Object[] array, int a, int b)

Description

swap

License

Open Source License

Declaration

public static void swap(Object[] array, int a, int b) 

Method Source Code

//package com.java2s;
/*//w w  w  . jav a  2s  .  c  o m
 * This file is part of the Jose Project
 * see http://jose-chess.sourceforge.net/
 * (c) 2002-2006 Peter Sch?fer
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 */

import java.util.List;

public class Main {
    public static void swap(Object[] array, int a, int b) {
        Object aux = array[a];
        array[a] = array[b];
        array[b] = aux;
    }

    public static void swap(List list, int a, int b) {
        Object aux = list.get(a);
        list.set(a, list.get(b));
        list.set(b, aux);
    }

    public static final int set(int flags, int set, boolean on) {
        return on ? (flags | set) : (flags & ~set);
    }
}

Related

  1. swap(Object aobj[], int i, int j, int k)
  2. swap(Object[] arr, int a, int b)
  3. swap(Object[] arr, int i, int j)
  4. swap(Object[] arr, int i, int j)
  5. swap(Object[] array)
  6. swap(Object[] x, int a, int b)
  7. swap(short x[], int a, int b)
  8. swap(short x[], int[] y, int a, int b)
  9. swap(short x[], T[] a2, int a, int b)