- java.lang.Object
-
- org.hsqldb.lib.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 HsqlArrayListHsqlArrayList(int initialCapacity)Creates a new instance with the given initial capacityHsqlArrayList(int initialCapacity, boolean minimize)Creates a new instance of HsqlArrayList that minimizes the size when emptyHsqlArrayList(E[] data, int count, boolean minimize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, E element)Inserts an element at the given indexbooleanadd(E element)Appends an element to the end of the listbooleanaddAll(E[] array)booleanaddAll(Collection<? extends E> other)voidclear()booleancontains(java.lang.Object o)Eget(int index)Gets the element at given positionE[]getArray()intindexOf(E o)returns the index of given object or -1 if not foundbooleanisEmpty()Iterator<E>iterator()intlastIndexOf(E o)Eremove(int index)Removes and returns the element at given positionbooleanremove(E o)Eset(int index, E element)Replaces the element at given positionvoidsetSize(int newSize)Increase or reduce the size, setting discarded or added elements to null.intsize()Returns the number of elements in the array listvoidsort(java.util.Comparator<? super E> c)java.lang.Object[]toArray()<T> T[]toArray(T[] array)Copies all elements of the list to a[].voidtoArraySlice(E[] array, int start, int limit)Copies elements of the list from start to limit to array.java.lang.StringtoString()voidtrim()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
-
-
-
-
Constructor Detail
-
HsqlArrayList
public HsqlArrayList(E[] data, int count, boolean minimize)
-
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- intminimize- 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
-
add
public boolean add(E element)
Appends an element to the end of the list
-
get
public E get(int index)
Gets the element at given position
-
indexOf
public int indexOf(E o)
returns the index of given object or -1 if not found- Parameters:
o- Object- Returns:
- int
-
contains
public boolean contains(java.lang.Object o)
- Specified by:
containsin interfaceCollection<E>
-
remove
public boolean remove(E o)
- Specified by:
removein interfaceCollection<E>
-
remove
public E remove(int index)
Removes and returns the element at given position
-
size
public final int size()
Returns the number of elements in the array list
-
trim
public void trim()
Trims the array to be the same size as the number of elements.
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<E>
-
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- intlimit- int
-
getArray
public E[] getArray()
-
sort
public void sort(java.util.Comparator<? super E> c)
-
lastIndexOf
public int lastIndexOf(E o)
-
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:
toStringin classjava.lang.Object
-
iterator
public Iterator<E> iterator()
-
-