org.ws4d.java.structures
Class ArrayList

java.lang.Object
  extended by org.ws4d.java.structures.DataStructure
      extended by org.ws4d.java.structures.List
          extended by org.ws4d.java.structures.ArrayList

public class ArrayList
extends List


Constructor Summary
ArrayList()
          Constructor.
ArrayList(DataStructure data)
          Constructor.
ArrayList(int initialCapacity)
          Constructor.
ArrayList(int initialCapacity, int capacityIncrement)
          Constructor.
ArrayList(Iterator it)
          Constructor.
 
Method Summary
 void add(int index, java.lang.Object obj)
           
 boolean add(java.lang.Object obj)
          Adds a new object to this data structure.
 void clear()
          Clears this data structure by removing all content from it.
 boolean contains(java.lang.Object obj)
          Checks whether obj (or another instance equal to obj in terms of java.lang.Object.equals(Object) ) is already present within this data structure instance and returns true only if this is the case.
 java.lang.Object get(int index)
           
 int indexOf(java.lang.Object o)
           
 int lastIndexOf(java.lang.Object o)
           
 java.lang.Object remove(int index)
           
 boolean remove(java.lang.Object o)
          Removes obj from this data structure.
 boolean removeAll(DataStructure data)
          Optimizing ArrayList.removeAll (see http://ahmadsoft.org/articles/removeall/index.html)
 java.lang.Object set(int index, java.lang.Object obj)
           
 java.lang.Object[] toArray()
          Returns an array containing all items stored within this data structure.
 java.lang.Object[] toArray(java.lang.Object[] array)
          Stores all contained items into the passed-in array objects.
 
Methods inherited from class org.ws4d.java.structures.List
addAll, addAll, equals, getClassShortName, iterator, listIterator, listIterator, size, subList
 
Methods inherited from class org.ws4d.java.structures.DataStructure
containsAll, hashCode, isEmpty, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ArrayList

public ArrayList()
Constructor.


ArrayList

public ArrayList(DataStructure data)
Constructor.

Parameters:
data -

ArrayList

public ArrayList(int initialCapacity)
Constructor.

Parameters:
initialCapacity -

ArrayList

public ArrayList(int initialCapacity,
                 int capacityIncrement)
Constructor.

Parameters:
initialCapacity -
capacityIncrement -

ArrayList

public ArrayList(Iterator it)
Constructor.

Parameters:
it -
Method Detail

add

public void add(int index,
                java.lang.Object obj)
Overrides:
add in class List

add

public boolean add(java.lang.Object obj)
Description copied from class: DataStructure
Adds a new object to this data structure.

Overrides:
add in class List
Parameters:
obj - the object to add
Returns:
true if the object was actually added, false in any other case (e.g. adding an object to a set which already contains the same object in terms of java.lang.Object.equals(Object))

clear

public void clear()
Description copied from class: DataStructure
Clears this data structure by removing all content from it.

Overrides:
clear in class DataStructure

contains

public boolean contains(java.lang.Object obj)
Description copied from class: DataStructure
Checks whether obj (or another instance equal to obj in terms of java.lang.Object.equals(Object) ) is already present within this data structure instance and returns true only if this is the case.

Overrides:
contains in class DataStructure
Parameters:
obj - the object to check the presence of
Returns:
true if obj is contained by this instance, false if not

get

public java.lang.Object get(int index)
Specified by:
get in class List

indexOf

public int indexOf(java.lang.Object o)
Overrides:
indexOf in class List

lastIndexOf

public int lastIndexOf(java.lang.Object o)
Overrides:
lastIndexOf in class List

remove

public java.lang.Object remove(int index)
Overrides:
remove in class List

remove

public boolean remove(java.lang.Object o)
Description copied from class: DataStructure
Removes obj from this data structure. Returns true if obj was actually present and thus it was really removed (i.e. this instance was modified by the method call).

Overrides:
remove in class DataStructure
Parameters:
o - the object to remove
Returns:
true only if obj was actually removed

removeAll

public boolean removeAll(DataStructure data)
Optimizing ArrayList.removeAll (see http://ahmadsoft.org/articles/removeall/index.html)


set

public java.lang.Object set(int index,
                            java.lang.Object obj)
Overrides:
set in class List

toArray

public java.lang.Object[] toArray()
Description copied from class: DataStructure
Returns an array containing all items stored within this data structure. The array will be of length DataStructure.size(), i.e. for an empty data structure an array of length zero is returned (rather than null).

Overrides:
toArray in class DataStructure
Returns:
an array of all objects contained within this data structure instance; this method never returns null

toArray

public java.lang.Object[] toArray(java.lang.Object[] array)
Description copied from class: DataStructure
Stores all contained items into the passed-in array objects. Returns the same array.

The array is expected not to be null and to be of exactly DataStructure.size() length. Otherwise, either a java.lang.NullPointerException or an java.lang.IllegalArgumentException will be thrown.

Overrides:
toArray in class DataStructure
Parameters:
array - the array to store this data structure's content to
Returns:
the same array as the one passed in (objects), however after having been filled with all objects contained within this data structure instance