elemental.util.

Interface ArrayOf<T>

  • Type Parameters:

    T -


    public interface ArrayOf<T>

    A lightweight array of homogeneous Object values.

    See Also:

    JsArrayOf

    • Method Summary

      All Methods
      Modifier and Type Method and Description
      ArrayOf<T> concat(ArrayOf<T> values)

      Returns a new array that is the concatenation of this array and values.

      boolean contains(T value)

      Indicates whether the array contains the specified value.

      T get(int index)

      Gets the value at a given index.

      int indexOf(T value)

      Returns the index of the specified value or -1 if the value is not found.

      void insert(int index, T value)

      Inserts a new element into the array at the specified index.

      boolean isEmpty()

      Returns true if the length of the array is zero.

      String join()

      Convert each element of the array to a String and join them with a comma separator.

      String join(String separator)

      Convert each element of the array to a String and join them with a comma separator.

      int length()

      Gets the length of the array.

      T peek()

      Returns the last value of the array;

      T pop()

      Remove and return the element from the end of the array.

      void push(T value)

      Pushes the given value onto the end of the array.

      void remove(T value)

      Searches for the specified value in the array and removes the first occurrence if found.

      void removeByIndex(int index)

      Removes the element at the specified index.

      void set(int index, T value)

      sets the value value at a given index.

      void setLength(int length)

      Reset the length of the array.

      T shift()

      Shifts the first value off the array.

      void sort(CanCompare<T> comparator)

      Sorts the contents of the Array based on the CanCompare.

      ArrayOf<T> splice(int index, int count)

      Removes the specified number of elements starting at index and returns the removed elements.

      void unshift(T value)

      Shifts a value onto the beginning of the array.

    • Method Detail

      • concat

        ArrayOf<T> concat(ArrayOf<T> values)

        Returns a new array that is the concatenation of this array and values. This method does not mutate the current array.

      • contains

        boolean contains(T value)

        Indicates whether the array contains the specified value.

      • get

        T get(int index)

        Gets the value at a given index.

        Parameters:

        index - the index to be retrieved

        Returns:

        the value at the given index

      • indexOf

        int indexOf(T value)

        Returns the index of the specified value or -1 if the value is not found.

      • insert

        void insert(int index,
                    T value)

        Inserts a new element into the array at the specified index. Note: If index >= the length of the array, the element will be appended to the end. Also if the index is negative, the element will be inserted starting from the end of the array.

      • isEmpty

        boolean isEmpty()

        Returns true if the length of the array is zero.

        Returns:

        true when length is zero

      • join

        String join()

        Convert each element of the array to a String and join them with a comma separator. The value returned from this method may vary between browsers based on how JavaScript values are converted into strings.

      • join

        String join(String separator)

        Convert each element of the array to a String and join them with a comma separator. The value returned from this method may vary between browsers based on how JavaScript values are converted into strings.

      • length

        int length()

        Gets the length of the array.

        Returns:

        the array length

      • peek

        T peek()

        Returns the last value of the array;

        Returns:

        the last value

      • pop

        T pop()

        Remove and return the element from the end of the array.

        Returns:

        the removed value

      • push

        void push(T value)

        Pushes the given value onto the end of the array.

      • remove

        void remove(T value)

        Searches for the specified value in the array and removes the first occurrence if found.

      • removeByIndex

        void removeByIndex(int index)

        Removes the element at the specified index.

      • set

        void set(int index,
                 T value)

        sets the value value at a given index. if the index is out of bounds, the value will still be set. the array's length will be updated to encompass the bounds implied by the added value.

        Parameters:

        index - the index to be set

        value - the value to be stored

      • setLength

        void setLength(int length)

        Reset the length of the array.

        Parameters:

        length - the new length of the array

      • shift

        T shift()

        Shifts the first value off the array.

        Returns:

        the shifted value

      • sort

        void sort(CanCompare<T> comparator)

        Sorts the contents of the Array based on the CanCompare.

        Parameters:

        comparator -

      • splice

        ArrayOf<T> splice(int index,
                          int count)

        Removes the specified number of elements starting at index and returns the removed elements.

      • unshift

        void unshift(T value)

        Shifts a value onto the beginning of the array.

        Parameters:

        value - the value to the stored