com.hazelcast.util.collection

## Class ArrayUtils

- java.lang.Object
- - com.hazelcast.util.collection.ArrayUtils

-     public final class ArrayUtils
      extends Object

  Convenient method for array manipulations.

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T> T[]` | `append(T[] array1, T[] array2)` Appends 2 arrays.
    `static void` | `boundsCheck(int capacity, int index, int length)` Bounds check when copying to/from a buffer
    `static <T> void` | `concat(T[] sourceFirst, T[] sourceSecond, T[] dest)` Copies in order `sourceFirst` and `sourceSecond` into `dest`.
    `static <T> boolean` | `contains(T[] array, T item)`
    `static <T> void` | `copyWithoutNulls(T[] src, T[] dst)` Copy src array into destination and skip null values.
    `static <T> T[]` | `createCopy(T[] src)` Create copy of the src array.
    `static <T> T` | `getItemAtPositionOrNull(T[] array, int position)`
    `static <T> T[]` | `remove(T[] src, T object)` Removes an item from the array.
    `static <T> T[]` | `replaceFirst(T[] src, T oldValue, T[] newValues)` Replaces the first occurrence of the oldValue by the newValue.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### createCopy

          public static <T> T[] createCopy(T[] src)

      Create copy of the src array.
      Type Parameters:
        `T` -
      Parameters:
        `src` -
      Returns:
        copy of the original array

    - #### remove

          public static <T> T[] remove(T[] src,
                                       T object)

      Removes an item from the array. If the item has been found, a new array is returned where this item is removed. Otherwise the original array is returned.
      Type Parameters:
        `T` - the type of the array
      Parameters:
        `src` - the src array
        `object` - the object to remove
      Returns:
        the resulting array

    - #### append

          public static <T> T[] append(T[] array1,
                                       T[] array2)

      Appends 2 arrays.
      Type Parameters:
        `T` - the type of the array
      Parameters:
        `array1` - the first array
        `array2` - the second array
      Returns:
        the resulting array

    - #### replaceFirst

          public static <T> T[] replaceFirst(T[] src,
                                             T oldValue,
                                             T[] newValues)

      Replaces the first occurrence of the oldValue by the newValue. If the item is found, a new array is returned. Otherwise the original array is returned.
      Type Parameters:
        `T` - the type of the array
      Parameters:
        `src` -
        `oldValue` - the value to look for
        `newValues` - the value that is inserted.
      Returns:

    - #### copyWithoutNulls

          public static <T> void copyWithoutNulls(T[] src,
                                                  T[] dst)

      Copy src array into destination and skip null values. Warning: It does not do any validation. It expect the dst[] is created with right capacity. You can calculate required capacity as `src.length - getNoOfNullItems(src)`
      Type Parameters:
        `T` -
      Parameters:
        `src` - source array
        `dst` - destination. It has to have the right capacity

    - #### contains

          public static <T> boolean contains(T[] array,
                                             T item)

    - #### getItemAtPositionOrNull

          public static <T> T getItemAtPositionOrNull(T[] array,
                                                      int position)

    - #### concat

          public static <T> void concat(T[] sourceFirst,
                                        T[] sourceSecond,
                                        T[] dest)

      Copies in order `sourceFirst` and `sourceSecond` into `dest`.
      Type Parameters:
        `T` -
      Parameters:
        `sourceFirst` -
        `sourceSecond` -
        `dest` -

    - #### boundsCheck

          public static void boundsCheck(int capacity,
                                         int index,
                                         int length)

      Bounds check when copying to/from a buffer
      Parameters:
        `capacity` - capacity of the buffer
        `index` - index of copying will start from/to
        `length` - length of the buffer that will be read/writen

Copyright © 2019. All rights reserved.