monrovia.tools
Class ArrayIDList

java.lang.Object
  |
  +--monrovia.tools.ArrayIDList
All Implemented Interfaces:
java.util.Collection, java.util.List

public class ArrayIDList
extends java.lang.Object
implements java.util.List

List implementation that gives unique IDs for the values.


Constructor Summary
ArrayIDList()
          Constructor.
 
Method Summary
 void add(int pIndex, java.lang.Object pObj)
           
 boolean add(java.lang.Object pObject)
          Add an object to the list.
 boolean addAll(java.util.Collection pCollection)
           
 boolean addAll(int pIndex, java.util.Collection pCollection)
           
 void clear()
          Clear the list.
 boolean contains(java.lang.Object pObj)
           
 boolean containsAll(java.util.Collection pCollection)
           
 java.lang.Object get(int pID)
          Get element with given ID.
 int getNextID()
          Get the next ID that will be used.
 int indexOf(java.lang.Object pObject)
          Searches for the first occurence of the given argument, testing for equality using the equals method.
 boolean isEmpty()
           
 java.util.Iterator iterator()
          Returns an iterator over the elements in this list in proper sequence.
 int lastIndexOf(java.lang.Object pObject)
          Searches for the last occurence of the give argument, testing for equality using the equals method.
 java.util.ListIterator listIterator()
           
 java.util.ListIterator listIterator(int pIndex)
           
 java.lang.Object remove(int pID)
          Frees the given ID.
 boolean remove(java.lang.Object pObj)
           
 boolean removeAll(java.util.Collection pCollection)
           
 boolean retainAll(java.util.Collection pCollection)
           
 java.lang.Object set(int pIndex, java.lang.Object pObj)
           
 int size()
           
 java.util.List subList(int pFrom, int pTo)
           
 java.lang.Object[] toArray()
           
 java.lang.Object[] toArray(java.lang.Object[] pArray)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
equals, hashCode
 

Constructor Detail

ArrayIDList

public ArrayIDList()
Constructor.
Method Detail

getNextID

public int getNextID()
Get the next ID that will be used.

add

public boolean add(java.lang.Object pObject)
Add an object to the list.

Specified by:
add in interface java.util.List
Parameters:
pObject - The object to add
Throws:
NullPointerException - If the pObject is null

clear

public void clear()
Clear the list.
Specified by:
clear in interface java.util.List

get

public java.lang.Object get(int pID)
Get element with given ID.

Specified by:
get in interface java.util.List
Parameters:
pID - ID of the wanted object
Returns:
The object or null if the ID is not in use

indexOf

public int indexOf(java.lang.Object pObject)
Searches for the first occurence of the given argument, testing for equality using the equals method.

Specified by:
indexOf in interface java.util.List
Parameters:
pObject - The object
Returns:
ID for the object or -1 if it was not found

lastIndexOf

public int lastIndexOf(java.lang.Object pObject)
Searches for the last occurence of the give argument, testing for equality using the equals method.

Specified by:
lastIndexOf in interface java.util.List
Parameters:
pObject - The object
Returns:
ID for the object or -1 if it was not found

iterator

public java.util.Iterator iterator()
Returns an iterator over the elements in this list in proper sequence.
Specified by:
iterator in interface java.util.List

remove

public java.lang.Object remove(int pID)
Frees the given ID.

Specified by:
remove in interface java.util.List
Parameters:
pID - ID to remove
Returns:
The object that was associated with the given ID or null if it was already free

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

size

public int size()
Specified by:
size in interface java.util.List

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.List

remove

public boolean remove(java.lang.Object pObj)
Specified by:
remove in interface java.util.List

contains

public boolean contains(java.lang.Object pObj)
Specified by:
contains in interface java.util.List

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.List

toArray

public java.lang.Object[] toArray(java.lang.Object[] pArray)
Specified by:
toArray in interface java.util.List

containsAll

public boolean containsAll(java.util.Collection pCollection)
Specified by:
containsAll in interface java.util.List

addAll

public boolean addAll(java.util.Collection pCollection)
Specified by:
addAll in interface java.util.List

addAll

public boolean addAll(int pIndex,
                      java.util.Collection pCollection)
Specified by:
addAll in interface java.util.List

removeAll

public boolean removeAll(java.util.Collection pCollection)
Specified by:
removeAll in interface java.util.List

retainAll

public boolean retainAll(java.util.Collection pCollection)
Specified by:
retainAll in interface java.util.List

set

public java.lang.Object set(int pIndex,
                            java.lang.Object pObj)
Specified by:
set in interface java.util.List

add

public void add(int pIndex,
                java.lang.Object pObj)
Specified by:
add in interface java.util.List

listIterator

public java.util.ListIterator listIterator()
Specified by:
listIterator in interface java.util.List

listIterator

public java.util.ListIterator listIterator(int pIndex)
Specified by:
listIterator in interface java.util.List

subList

public java.util.List subList(int pFrom,
                              int pTo)
Specified by:
subList in interface java.util.List