|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.enough.polish.util.ArrayList<K>
K - when you use the enough-polish-client-java5.jar you can parameterize the ArrayList, e.g. ArrayList<Integer> = new ArrayList<Integer>(10);
Copyright (c) Enough Software 2005 - 2009
public class ArrayList<K>
Provides an flexible list for storing objects.
This ArrayList is mostly compatible with the java.util.ArrayList of the J2SE. It lacks, however, some not often used methods. Also some methods like add or remove do not return a boolean value, since true is always returned (or an exception is thrown) anyhow. This way we can save some precious space!
Workarounds for some of the missing methods:
| Constructor Summary | |
|---|---|
ArrayList()
Creates an ArrayList with the initial capacity of 10 and a growth factor of 75% |
|
ArrayList(int initialCapacity)
Creates an ArrayList with the given initial capacity and a growth factor of 75% |
|
ArrayList(int initialCapacity,
int growthFactor)
Creates a new ArrayList |
|
| Method Summary | |
|---|---|
void |
add(int index,
K element)
Inserts the given element at the defined position. |
void |
add(K element)
Stores the given element in this list. |
void |
addAll(ArrayList list)
Adds all elements of the given list to this list. |
void |
addAll(Object[] elements)
Adds all elements to this list. |
void |
addAll(Object[] elements,
int offset,
int len)
Adds all elements to this list. |
void |
clear()
Removes all of the elements from this list. |
boolean |
contains(K element)
Determines whether the given element is stored in this list. |
K |
get(int index)
Returns the element at the specified position in this list. |
Object[] |
getInternalArray()
Retrieves the internal array - use with care! This method allows to access stored objects without creating an intermediate array. |
int |
indexOf(K element)
Retrieves the index of the given object. |
void |
read(DataInputStream in)
Restores the internal instance fields from the given input stream. |
K |
remove(int index)
Removes the element at the specified position in this list. |
boolean |
remove(K element)
Removes the given element. |
K |
set(int index,
K element)
Replaces the element at the specified position in this list with the specified element. |
int |
size()
Retrieves the current size of this array list. |
Object[] |
toArray()
Returns all stored elements as an array. |
K[] |
toArray(K[] target)
Returns all stored elements in the given array. |
String |
toString()
Returns String containing the String representations of all objects of this list. |
void |
trimToSize()
Trims the capacity of this ArrayList instance to be the list's current size. |
void |
write(DataOutputStream out)
Stores the internal instance fields to the output stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ArrayList()
public ArrayList(int initialCapacity)
initialCapacity - the capacity of this array list.
public ArrayList(int initialCapacity,
int growthFactor)
initialCapacity - the capacity of this array list.growthFactor - the factor in % for increasing the capacity
when there's not enough room in this list anymore| Method Detail |
|---|
public int size()
public boolean contains(K element)
element - the element which might be stored in this list
IllegalArgumentException - when the given element is nullremove(Object)public int indexOf(K element)
element - the object which is part of this list.
IllegalArgumentException - when the given element is nullpublic K get(int index)
index - the position of the desired element.
IndexOutOfBoundsException - when the index < 0 || index >= size()public K remove(int index)
index - the position of the desired element.
IndexOutOfBoundsException - when the index < 0 || index >= size()public boolean remove(K element)
element - the element which should be removed.
IllegalArgumentException - when the given element is nullcontains(Object)public void clear()
public void add(K element)
element - the element which should be appended to this list.
IllegalArgumentException - when the given element is nulladd( int, Object )
public void add(int index,
K element)
index - the position at which the element should be inserted,
use 0 when the element should be inserted in the front of this list.element - the element which should be inserted
IllegalArgumentException - when the given element is null
IndexOutOfBoundsException - when the index < 0 || index >= size()
public K set(int index,
K element)
index - the position of the element, the first element has the index 0.element - the element which should be set
IndexOutOfBoundsException - when the index < 0 || index >= size()public String toString()
toString in class Objectpublic Object[] toArray()
public K[] toArray(K[] target)
target - the array in which the stored elements should be copied.
public void trimToSize()
public Object[] getInternalArray()
public void addAll(ArrayList list)
list - the list
NullPointerException - when the specified list is nullpublic void addAll(Object[] elements)
elements - the array elements
NullPointerException - when an element is null or the array is null
public void addAll(Object[] elements,
int offset,
int len)
elements - the array elementsoffset - the start indexlen - the number of elements that should be copied
NullPointerException - when an element is null or the array is null
public void read(DataInputStream in)
throws IOException
Externalizable
read in interface Externalizablein - the input stream from which the data is loaded
IOException - when reading fails
public void write(DataOutputStream out)
throws IOException
Externalizable
write in interface Externalizableout - the output stream to which instance fields should be written
IOException - when writing fails
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||