Module org.hsqldb

Class HsqlArrayList<E>

java.lang.Object
org.hsqldb.lib.HsqlArrayList<E>
All Implemented Interfaces:
Collection<E>, List<E>
Direct Known Subclasses:
ArrayListIdentity

public class HsqlArrayList<E> extends Object implements List<E>
Intended as an asynchronous alternative to Vector.
Since:
1.7.0
Author:
dnordahl@users
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance of HsqlArrayList
    HsqlArrayList(int initialCapacity)
    Creates a new instance with the given initial capacity
    HsqlArrayList(int initialCapacity, boolean minimize)
    Creates a new instance of HsqlArrayList that minimizes the size when empty
    HsqlArrayList(E[] data, int count)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(int index, E element)
    Inserts an element at the given index
    boolean
    add(E element)
    Appends an element to the end of the list
    boolean
    addAll(E[] array)
     
    boolean
    addAll(Collection<? extends E> other)
     
    void
     
    boolean
    contains(Object element)
     
    get(int index)
    Gets the element at given position
    E[]
     
    int
    returns the index of given object or -1 if not found
    boolean
     
     
    int
     
    remove(int index)
    Removes and returns the element at given position
    boolean
    remove(Object element)
     
    set(int index, E element)
    Replaces the element at given position
    void
    setSize(int newSize)
    Increase or reduce the size, setting discarded or added elements to null.
    final int
    Returns the number of elements in the array list
    void
    sort(Comparator<? super E> c)
     
     
    <T> T[]
    toArray(T[] array)
    Copies all elements of the list to a[].
    void
    toArraySlice(E[] array, int start, int limit)
    Copies elements of the list from start to limit to array.
     
    void
    Trims the array to be the same size as the number of elements.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.hsqldb.lib.Collection

    addAll, contains, remove

    Methods inherited from interface org.hsqldb.lib.List

    isEmpty, iterator
  • Constructor Details

    • HsqlArrayList

      public HsqlArrayList(E[] data, int count)
    • HsqlArrayList

      public HsqlArrayList()
      Creates a new instance of HsqlArrayList
    • HsqlArrayList

      public HsqlArrayList(int initialCapacity, boolean minimize)
      Creates a new instance of HsqlArrayList that minimizes the size when empty
      Parameters:
      initialCapacity - int
      minimize - boolean
    • HsqlArrayList

      public HsqlArrayList(int initialCapacity)
      Creates a new instance with the given initial capacity
      Parameters:
      initialCapacity - int
  • Method Details

    • add

      public void add(int index, E element)
      Inserts an element at the given index
      Specified by:
      add in interface List<E>
      Parameters:
      index - int
      element - E
    • add

      public boolean add(E element)
      Appends an element to the end of the list
      Specified by:
      add in interface Collection<E>
      Specified by:
      add in interface List<E>
      Parameters:
      element - E
      Returns:
      boolean
    • get

      public E get(int index)
      Gets the element at given position
      Specified by:
      get in interface List<E>
      Parameters:
      index - int
      Returns:
      E
    • indexOf

      public int indexOf(Object o)
      returns the index of given object or -1 if not found
      Parameters:
      o - Object
      Returns:
      int
    • remove

      public E remove(int index)
      Removes and returns the element at given position
      Specified by:
      remove in interface List<E>
      Parameters:
      index - int
      Returns:
      E
    • set

      public E set(int index, E element)
      Replaces the element at given position
      Specified by:
      set in interface List<E>
      Parameters:
      index - int
      element - E
      Returns:
      E
    • size

      public final int size()
      Returns the number of elements in the array list
      Specified by:
      size in interface Collection<E>
      Specified by:
      size in interface List<E>
      Returns:
      int
    • trim

      public void trim()
      Trims the array to be the same size as the number of elements.
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<E>
    • setSize

      public void setSize(int newSize)
      Increase or reduce the size, setting discarded or added elements to null.
      Parameters:
      newSize - int
    • toArray

      public Object[] toArray()
    • toArray

      public <T> T[] toArray(T[] array)
      Copies all elements of the list to a[].

      If a[] is too small, a new array or the same type is returned.

      If a[] is larger, only the list elements are copied and no other change is made to the array.

      Differs from the implementation in java.util.ArrayList in the second aspect.

      Type Parameters:
      T - type of array element
      Parameters:
      array - T[]
      Returns:
      T[]
    • toArraySlice

      public void toArraySlice(E[] array, int start, int limit)
      Copies elements of the list from start to limit to array. The array must be large enough.
      Parameters:
      array - E[]
      start - int
      limit - int
    • getArray

      public E[] getArray()
    • sort

      public void sort(Comparator<? super E> c)
    • lastIndexOf

      public int lastIndexOf(Object o)
    • contains

      public boolean contains(Object element)
    • remove

      public boolean remove(Object element)
    • addAll

      public boolean addAll(Collection<? extends E> other)
    • addAll

      public boolean addAll(E[] array)
    • isEmpty

      public boolean isEmpty()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • iterator

      public Iterator<E> iterator()