gausssoft.collections
Class ArraySet

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.ArrayList
                    |
                    +--gausssoft.collections.ArraySet
All Implemented Interfaces:
Cloneable, CloneableObject, Collection, List, Serializable, Set, SetList

public class ArraySet
extends ArrayList
implements SetList, CloneableObject

The ArraySet class is a subclass of the ArrayList class, simply ensuring that all elements in the collection are unique, as defined by the Set interface.

Author:
Allan Crooks
See Also:
ArrayList, Set, SetList, Serialized Form

Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ArraySet()
          Constructs an empty ArraySet.
ArraySet(Collection c)
          Constructs an ArraySet containing the elements of the specified collection.
ArraySet(int size)
          Constructs an empty ArraySet of a specified with the specified initial capacity.
 
Method Summary
 void add(int index, Object element)
          Inserts the specified object into the specified position in the list.
 boolean add(Object element)
          Appends this element at the end of the list (if it doesn't already exist in the collection).
 boolean addAll(Collection c)
          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.
 boolean addAll(int index, Collection c)
          Appends all of the elements in the specified collection into this list, starting at the specified position.
 Object set(int index, Object element)
          Replaces the element at the specified position in this list with the specifed element.
 
Methods inherited from class java.util.ArrayList
clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, remove, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface java.util.List
clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, size, subList, toArray, toArray
 
Methods inherited from interface gausssoft.lang.CloneableObject
clone
 

Constructor Detail

ArraySet

public ArraySet(int size)
Constructs an empty ArraySet of a specified with the specified initial capacity.
Parameters:
size - The initial size of the ArraySet.
Throws:
IllegalArgumentException - If the specified initial capacity is negative.

ArraySet

public ArraySet()
Constructs an empty ArraySet.


ArraySet

public ArraySet(Collection c)
Constructs an ArraySet containing the elements of the specified collection.

The initial capacity of the ArraySet will be 110% of the size of the provided collection.

Parameters:
c - The collection whose elements are to be placed in this list.
Throws:
NullPointerException - If c is null.
Method Detail

set

public Object set(int index,
                  Object element)
Replaces the element at the specified position in this list with the specifed element.
Specified by:
set in interface List
Overrides:
set in class ArrayList
Parameters:
index - Index of element to replace.
element - The element to store at the specified position.
Returns:
The previous object at the specified position.
Throws:
IndexOutOfBoundsException - If the index specified is invalid.
IllegalArgumentException - If the object provided is already in this collection.

add

public boolean add(Object element)
Appends this element at the end of the list (if it doesn't already exist in the collection).
Specified by:
add in interface Set
Overrides:
add in class ArrayList
Parameters:
element - The object to add to this collection.
Returns:
true if this object was modified as a result of this call.

add

public void add(int index,
                Object element)
Inserts the specified object into the specified position in the list.
Specified by:
add in interface List
Overrides:
add in class ArrayList
Parameters:
index - The index position to insert the specified object in the list.
element - The object to insert into the list.
Throws:
IndexOutOfBoundsException - If the index specified is invalid.
IllegalArgumentException - If the object provided is already in this collection.

addAll

public boolean addAll(Collection c)
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. If any items already exist in this object, they will not be added to the list.
Specified by:
addAll in interface Set
Overrides:
addAll in class ArrayList
Parameters:
c - The collection whose elements are to be placed in this list.
Returns:
true if this method caused this collection to be modified.

addAll

public boolean addAll(int index,
                      Collection c)
Appends all of the elements in the specified collection into this list, starting at the specified position. If any items already exist in this object, they will not be added to the list.
Specified by:
addAll in interface List
Overrides:
addAll in class ArrayList
Parameters:
index - The index position to begin entering items into the list.
c - The collection whose elements are to be placed in this list.
Returns:
true if this method caused this collection to be modified.