Java Array arraySeekDelete(final T[] arr, final T[] dest, final T... dels)

Here you can find the source of arraySeekDelete(final T[] arr, final T[] dest, final T... dels)

Description

array Seek Delete

License

Open Source License

Declaration

public static <T> T[] arraySeekDelete(final T[] arr, final T[] dest, final T... dels) 

Method Source Code

//package com.java2s;
/*//  w  w w  . ja  v  a 2s  . c  om
 *  Copyright (C) 2011-2014 Brian Groenke
 *  All rights reserved.
 * 
 *  This file is part of the 2DX Graphics Library.
 *
 *  This Source Code Form is subject to the terms of the
 *  Mozilla Public License, v. 2.0. If a copy of the MPL 
 *  was not distributed with this file, You can obtain one at 
 *  http://mozilla.org/MPL/2.0/.
 */

public class Main {
    public static <T> T[] arraySeekDelete(final T[] arr, final T[] dest, final T... dels) {

        if (arr == null || dest == null || dest.length != arr.length - dels.length) {
            throw (new IllegalArgumentException("null or invalid array argument"));
        }
        for (int i = 0; i < dels.length; i++) {
            for (int ii = 0, offs = 0; ii < arr.length; ii++) {
                if (ii >= dest.length) {
                    return null;
                }
                if (arr[ii] != dels[i]) {
                    dest[ii - offs] = arr[ii];
                } else {
                    offs++;
                }
            }
        }

        return dest;
    }
}

Related

  1. arrayPush(String[] array, String push)
  2. arrayRangeEquals(byte[] a, int aOffset, byte[] b, int bOffset, int byteCount)
  3. arrayRepresentsProbability(double[] probs)
  4. arraySame(Object[] array1, Object[] array2)
  5. arraysConvert(String[] src, int column)
  6. arrayStr(int[] A)
  7. arrayString(double[] test)
  8. arrayString(int[] data)
  9. arrayStringR(double[] data)