Java Array Element Get getItems(T[] items, int[] indices)

Here you can find the source of getItems(T[] items, int[] indices)

Description

get Items

License

Open Source License

Declaration

public static <T> T[] getItems(T[] items, int[] indices) 

Method Source Code

//package com.java2s;
/* ***** BEGIN LICENSE BLOCK *****
 *
 * This file is part of Weave./* w  w  w. j a  va 2s  .  c  o m*/
 *
 * The Initial Developer of Weave is the Institute for Visualization
 * and Perception Research at the University of Massachusetts Lowell.
 * Portions created by the Initial Developer are Copyright (C) 2008-2015
 * the Initial Developer. All Rights Reserved.
 *
 * 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/.
 * 
 * ***** END LICENSE BLOCK ***** */

import java.util.Arrays;

public class Main {
    public static <T> T[] getItems(T[] items, int[] indices) {
        T[] result = Arrays.copyOf(items, indices.length);
        for (int i = 0; i < indices.length; i++)
            result[i] = items[indices[i]];
        return result;
    }
}

Related

  1. getArrayPreview(final Object[] array, final int previewSize)
  2. getArrays(byte[] inputArray, int arraySize, boolean zeroPad)
  3. getArraySubset(T[] array, int start, int end)
  4. getFrequentElement(int[] bcp)
  5. getFrequentElement(int[] bcp)
  6. getlast(final T[] array)
  7. getLast(T[] l)
  8. tail(int[] original)
  9. tail(Object[] array)