## org.h2.util
Class ObjectArray<T>

    java.lang.Object
      org.h2.util.ObjectArray<T>

Type Parameters:
  `T` - the element type

All Implemented Interfaces:
  java.lang.Iterable<T>

    public class ObjectArray<T>

extends java.lang.Object
implements java.lang.Iterable<T>

The object array is basically the same as ArrayList. It is a bit faster than ArrayList in some versions of Java.

Method Summary
`void` `add(int index, T value)` Insert an element at the given position.
`void` `add(T value)` Append an object at the end of the list.
`void` `addAll(ObjectArray<? extends T> list)` Add all objects from the given list.
`void` `clear()` Remove all elements from the list.
`T` `get(int index)` Get the object at the given index.
`int` `indexOf(java.lang.Object o)` Get the index of the given object, or -1 if not found.
`java.util.Iterator<T>` `iterator()`

`static

`<T> ObjectArray<T>`

`

`newInstance()`
Create a new object with the default initial capacity.

`static

`<T> ObjectArray<T>`

`

`newInstance(java.util.Collection<T> collection)`
Create a new object with all elements of the given collection.

`static

`<T> ObjectArray<T>`

`

`newInstance(int capacity)`
Create a new object with the given initial capacity.

`static

`<T> ObjectArray<T>`

`

`newInstance(T... list)`
Create a new object with the given values.

`java.lang.Object` `remove(int index)` Remove the object at the given index.
`void` `removeRange(int from, int to)` Remove a number of elements from the given start and end index.
`void` `set(int index, T value)` Update the object at the given index.
`void` `setSize(int size)` Fill the list with empty elements until it reaches the given size.
`int` `size()` Get the size of the list.
`void` `sort(java.util.Comparator<T> comp)` Sort the elements using the given comparator.
`T[]` `toArray(T[] array)` Convert this list to an array.
`java.lang.String` `toString()`
`void` `trimToSize()` Shrink the array to the required size.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Method Detail

### newInstance

    public static <T> ObjectArray<T> newInstance(int capacity)

  Create a new object with the given initial capacity.

  Parameters:
    `capacity` - the initial capacity
  Returns:
    the object

### newInstance

    public static <T> ObjectArray<T> newInstance(T... list)

  Create a new object with the given values.

  Parameters:
    `list` - the initial elements
  Returns:
    the object

### newInstance

    public static <T> ObjectArray<T> newInstance()

  Create a new object with the default initial capacity.

  Returns:
    the object

### newInstance

    public static <T> ObjectArray<T> newInstance(java.util.Collection<T> collection)

  Create a new object with all elements of the given collection.

  Parameters:
    `collection` - the collection with all elements
  Returns:
    the object

### add

    public void add(T value)

  Append an object at the end of the list.

  Parameters:
    `value` - the value

### get

    public T get(int index)

  Get the object at the given index.

  Parameters:
    `index` - the index
  Returns:
    the value

### remove

    public java.lang.Object remove(int index)

  Remove the object at the given index.

  Parameters:
    `index` - the index
  Returns:
    the removed object

### removeRange

    public void removeRange(int from,
                            int to)

  Remove a number of elements from the given start and end index.

  Parameters:
    `from` - the start index
    `to` - the end index

### setSize

    public void setSize(int size)

  Fill the list with empty elements until it reaches the given size.

  Parameters:
    `size` - the new size

### trimToSize

    public void trimToSize()

  Shrink the array to the required size.

### add

    public void add(int index,
                    T value)

  Insert an element at the given position. The element at this position and all elements with a higher index move one element.

  Parameters:
    `index` - the index where to insert the object
    `value` - the object to insert

### set

    public void set(int index,
                    T value)

  Update the object at the given index.

  Parameters:
    `index` - the index
    `value` - the new value

### size

    public int size()

  Get the size of the list.

  Returns:
    the size

### toArray

    public T[] toArray(T[] array)

  Convert this list to an array. The target array must be big enough.

  Parameters:
    `array` - the target array
  Returns:
    the array

### clear

    public void clear()

  Remove all elements from the list.

### indexOf

    public int indexOf(java.lang.Object o)

  Get the index of the given object, or -1 if not found.

  Parameters:
    `o` - the object to search
  Returns:
    the index

### addAll

    public void addAll(ObjectArray<? extends T> list)

  Add all objects from the given list.

  Parameters:
    `list` - the list

### sort

    public void sort(java.util.Comparator<T> comp)

  Sort the elements using the given comparator.

  Parameters:
    `comp` - the comparator

### iterator

    public java.util.Iterator<T> iterator()

  Specified by:
    `iterator` in interface `java.lang.Iterable<T>`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`