net.walend.collection
Class MutableArrayList

java.lang.Object
  |
  +--net.walend.collection.AbstractArrayList
        |
        +--net.walend.collection.MutableArrayList
All Implemented Interfaces:
Collection, HasState, List, MutableCollection, MutableList

public class MutableArrayList
extends AbstractArrayList
implements MutableList

add() appends the object to the end of the list. addAll() appends all of the objects to the end of the list.

Since:
20010909
Author:
David Walend

Nested Class Summary
 
Nested classes inherited from class net.walend.collection.AbstractArrayList
AbstractArrayList.ListItr
 
Field Summary
 
Fields inherited from class net.walend.collection.AbstractArrayList
modCount
 
Fields inherited from interface net.walend.collection.List
EMPTY
 
Constructor Summary
MutableArrayList()
           
MutableArrayList(Collection collection)
           
MutableArrayList(java.util.Collection collection)
           
MutableArrayList(Identitor ident)
           
MutableArrayList(Identitor ident, int initialCapacity)
           
MutableArrayList(int initialCapacity)
           
 
Method Summary
 boolean add(int index, java.lang.Object ob)
          Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
 boolean add(java.lang.Object object)
          Adds a Object to the MutableCollection.
 boolean addAll(Collection c)
          Adds all the Objects in c to this MutableCollection by using the add() method.
 boolean addAll(int index, Collection col)
          Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation).
 void clear()
          Removes all of the Objects in this collection.
 java.lang.Object remove(int index)
          Removes and returns the object at index in this list.
 boolean remove(java.lang.Object object)
          Removes a Object from the MutableCollection.
 boolean removeAll(Collection c)
          Removes all the Objects in c from this MutableCollection by using the remove() method.
 boolean retainAll(Collection c)
          Retains only the Objects in this collection that are contained in c by using the contains() and remove() methods.
 java.lang.Object set(int index, java.lang.Object ob)
          Replaces the element at the specified position in this list with the specified element
 
Methods inherited from class net.walend.collection.AbstractArrayList
checkRange, checkRangeForAdd, contains, containsAll, ensureCapacity, get, getIdentitor, getJavaCollection, getJavaList, getPrincipleInterface, indexOf, indexOfSubList, isEmpty, iterator, lastIndexOf, listIterator, listIterator, sameContentsAs, sameListAs, sameStateAs, size, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.walend.collection.Collection
contains, containsAll, getIdentitor, getJavaCollection, isEmpty, iterator, sameContentsAs, size
 
Methods inherited from interface net.walend.collection.HasState
getPrincipleInterface, sameStateAs
 
Methods inherited from interface net.walend.collection.List
get, getJavaList, indexOf, indexOfSubList, lastIndexOf, listIterator, listIterator, sameListAs
 

Constructor Detail

MutableArrayList

public MutableArrayList()

MutableArrayList

public MutableArrayList(int initialCapacity)

MutableArrayList

public MutableArrayList(Collection collection)

MutableArrayList

public MutableArrayList(java.util.Collection collection)

MutableArrayList

public MutableArrayList(Identitor ident)

MutableArrayList

public MutableArrayList(Identitor ident,
                        int initialCapacity)
Method Detail

add

public boolean add(java.lang.Object object)
Adds a Object to the MutableCollection. Sets will only add it to the Set if it's not already there.

Specified by:
add in interface MutableCollection
Overrides:
add in class AbstractArrayList
Returns:
true if the MutableCollection changes, false if not.

remove

public boolean remove(java.lang.Object object)
Removes a Object from the MutableCollection.

Specified by:
remove in interface MutableCollection
Overrides:
remove in class AbstractArrayList
Returns:
true if the MutableCollection changes, false if not.

addAll

public boolean addAll(Collection c)
Adds all the Objects in c to this MutableCollection by using the add() method. Returns true if this MutableCollection changes.

Specified by:
addAll in interface MutableCollection
Overrides:
addAll in class AbstractArrayList

removeAll

public boolean removeAll(Collection c)
Removes all the Objects in c from this MutableCollection by using the remove() method. Returns true if this Colleciton changes.

Specified by:
removeAll in interface MutableCollection
Overrides:
removeAll in class AbstractArrayList

retainAll

public boolean retainAll(Collection c)
Retains only the Objects in this collection that are contained in c by using the contains() and remove() methods. Returns true if this Colleciton changes.

Specified by:
retainAll in interface MutableCollection
Overrides:
retainAll in class AbstractArrayList

clear

public void clear()
Removes all of the Objects in this collection.

Specified by:
clear in interface MutableCollection
Overrides:
clear in class AbstractArrayList

add

public boolean add(int index,
                   java.lang.Object ob)
Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Specified by:
add in interface MutableList
Overrides:
add in class AbstractArrayList
Returns:
true
Throws:
java.lang.IndexOutOfBoundsException - if the index is not in the list.

addAll

public boolean addAll(int index,
                      Collection col)
Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation). The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)

Specified by:
addAll in interface MutableList
Overrides:
addAll in class AbstractArrayList
Returns:
true
Throws:
java.lang.IndexOutOfBoundsException - if the index is not in the list.

remove

public java.lang.Object remove(int index)
Removes and returns the object at index in this list. Shifts any following elements forward in the list.

Specified by:
remove in interface MutableList
Overrides:
remove in class AbstractArrayList
Returns:
the object removed from the list.
Throws:
java.lang.IndexOutOfBoundsException - if the index is not in the list.

set

public java.lang.Object set(int index,
                            java.lang.Object ob)
Replaces the element at the specified position in this list with the specified element

Specified by:
set in interface MutableList
Overrides:
set in class AbstractArrayList
Returns:
the object that was at index.
Throws:
java.lang.IndexOutOfBoundsException - if the index is not in the list.


Copyright (c) 2000, 2001, David Walend