Module org.hsqldb

Class HsqlArrayList<E>

  • All Implemented Interfaces:
    Collection<E>, List<E>
    Direct Known Subclasses:
    ArrayListIdentity

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

      Constructors 
      Constructor Description
      HsqlArrayList()
      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

      All Methods Instance Methods Concrete Methods 
      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 clear()  
      boolean contains​(java.lang.Object element)  
      E get​(int index)
      Gets the element at given position
      E[] getArray()  
      int indexOf​(java.lang.Object o)
      returns the index of given object or -1 if not found
      boolean isEmpty()  
      Iterator<E> iterator()  
      int lastIndexOf​(java.lang.Object o)  
      E remove​(int index)
      Removes and returns the element at given position
      boolean remove​(java.lang.Object element)  
      E 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.
      int size()
      Returns the number of elements in the array list
      void sort​(java.util.Comparator<? super E> c)  
      java.lang.Object[] toArray()  
      <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.
      java.lang.String toString()  
      void trim()
      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
    • Constructor Detail

      • 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 Detail

      • 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​(java.lang.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.
      • setSize

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

        public java.lang.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​(java.util.Comparator<? super E> c)
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object o)
      • contains

        public boolean contains​(java.lang.Object element)
      • remove

        public boolean remove​(java.lang.Object element)
      • addAll

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

        public boolean addAll​(E[] array)
      • isEmpty

        public boolean isEmpty()
      • toString

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

        public Iterator<E> iterator()