Java Array Swap swapOrder16(byte[] buffer, int byteOffset, int sampleCount)

Here you can find the source of swapOrder16(byte[] buffer, int byteOffset, int sampleCount)

Description

swap Order

License

Open Source License

Declaration

public static void swapOrder16(byte[] buffer, int byteOffset,
            int sampleCount) 

Method Source Code

//package com.java2s;

public class Main {
    public static void swapOrder16(byte[] buffer, int byteOffset,
            int sampleCount) {
        int byteMax = sampleCount * 2 + byteOffset - 1;
        int i = byteOffset;
        while (i < byteMax) {
            byte h = buffer[i];
            buffer[i] = buffer[++i];//from www  .ja  v a2  s .  co m
            buffer[i++] = h;
        }
    }

    public static void swapOrder16(byte[] inBuffer, int inByteOffset,
            byte[] outBuffer, int outByteOffset, int sampleCount) {
        while (sampleCount > 0) {
            outBuffer[outByteOffset++] = inBuffer[inByteOffset + 1];
            outBuffer[outByteOffset++] = inBuffer[inByteOffset++];
            inByteOffset++;
            sampleCount--;
        }
    }
}

Related

  1. swapEndianFormat(byte[] b)
  2. swapInt(byte[] b, int i)
  3. swapInts(byte b[], int off, int len)
  4. swapNumbers(int i, int j, double[] array)
  5. swapObjects(Object[] array, int a, int b)
  6. swapOrder32(byte[] buffer, int byteOffset, int sampleCount)
  7. swapParallel(Object[] x, Object[] y, int a, int b, int yrel)
  8. swapPerTowElement(int[] arr)
  9. swapReferences(Object[] a, int index1, int index2)