Here you can find the source of swap(int array[], int first, int last)
Parameter | Description |
---|---|
array | array of integers to be flipped |
first | starting element of the array |
last | last element of array to flip |
public static void swap(int array[], int first, int last)
//package com.java2s; /*/*w ww.ja v a 2 s. c o m*/ This source file is part of the edu.wisc.ssec.mcidas package and is Copyright (C) 1998 - 2011 by Tom Whittaker, Tommy Jasmin, Tom Rink, Don Murray, James Kelly, Bill Hibbard, Dave Glowacki, Curtis Rueden and others. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ public class Main { /** * swap the bytes of an integer array * * @param array array of integers to be flipped * @param first starting element of the array * @param last last element of array to flip * */ public static void swap(int array[], int first, int last) { int i, k; for (i = first; i <= last; i++) { k = array[i]; array[i] = ((k >>> 24) & 0xff) | ((k >>> 8) & 0xff00) | ((k & 0xff) << 24) | ((k & 0xff00) << 8); } } }