com.darwinsys.util
Class IndexList

java.lang.Object
  extended bycom.darwinsys.util.IndexList
All Implemented Interfaces:
java.util.Collection, java.util.List

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

A general-purpose List, in which objects keep their identity (index), that is, insert() operations do not renumber remaining objects. Hence, more like a real array than an ArrayList is(!).

Not necessarily for production use; written as an example of implementing the List interface.


Field Summary
static int DEFAULT_START_SIZE
          The initial size of an instance's internal store
 
Constructor Summary
IndexList()
           
IndexList(int startSize)
           
 
Method Summary
 void add(int i, java.lang.Object o)
          Unlike the general contract of List, this will replace, not insert before, the object at the given index.
 boolean add(java.lang.Object o)
          Add the given object to the end of the list
 boolean addAll(java.util.Collection c)
           
 boolean addAll(int i, java.util.Collection c)
           
 void clear()
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection c)
           
 void ensureCapacity(int i)
           
 java.lang.Object get(int i)
           
 int hashCode()
           
 int indexOf(java.lang.Object o)
          Find the location where this object is referenced, or null
 boolean isEmpty()
           
 java.util.Iterator iterator()
           
 int lastIndexOf(java.lang.Object o)
           
 java.util.ListIterator listIterator()
           
 java.util.ListIterator listIterator(int i)
           
 java.lang.Object remove(int i)
          remove() simply sets the given value to null.
 boolean remove(java.lang.Object o)
          remove() simply sets the given value to null.
 boolean removeAll(java.util.Collection c)
          removeAll removes all the elements in a Collection from this List
NOT IMPLEMENTED.
 boolean retainAll(java.util.Collection c)
           
 java.lang.Object set(int i, java.lang.Object o)
           
 int size()
           
 java.util.List subList(int from, int to)
           
 java.lang.Object[] toArray()
          Return the collection as an Array of Object
 java.lang.Object[] toArray(java.lang.Object[] newData)
          Return the collection as an Array of newData's type
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.List
equals
 

Field Detail

DEFAULT_START_SIZE

public static final int DEFAULT_START_SIZE
The initial size of an instance's internal store

See Also:
Constant Field Values
Constructor Detail

IndexList

public IndexList()

IndexList

public IndexList(int startSize)
Method Detail

ensureCapacity

public void ensureCapacity(int i)

size

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

isEmpty

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

contains

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

add

public boolean add(java.lang.Object o)
Add the given object to the end of the list

Specified by:
add in interface java.util.List

remove

public boolean remove(java.lang.Object o)
remove() simply sets the given value to null.

Specified by:
remove in interface java.util.List

remove

public java.lang.Object remove(int i)
remove() simply sets the given value to null.

Specified by:
remove in interface java.util.List

removeAll

public boolean removeAll(java.util.Collection c)
removeAll removes all the elements in a Collection from this List
NOT IMPLEMENTED.

Specified by:
removeAll in interface java.util.List

iterator

public java.util.Iterator iterator()
Specified by:
iterator in interface java.util.List

toArray

public java.lang.Object[] toArray()
Return the collection as an Array of Object

Specified by:
toArray in interface java.util.List

toArray

public java.lang.Object[] toArray(java.lang.Object[] newData)
Return the collection as an Array of newData's type

Specified by:
toArray in interface java.util.List

containsAll

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

addAll

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

addAll

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

retainAll

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

clear

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

hashCode

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

get

public java.lang.Object get(int i)
Specified by:
get in interface java.util.List

set

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

add

public void add(int i,
                java.lang.Object o)
Unlike the general contract of List, this will replace, not insert before, the object at the given index.

Specified by:
add in interface java.util.List

indexOf

public int indexOf(java.lang.Object o)
Find the location where this object is referenced, or null

Specified by:
indexOf in interface java.util.List

lastIndexOf

public int lastIndexOf(java.lang.Object o)
Specified by:
lastIndexOf 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 i)
Specified by:
listIterator in interface java.util.List

subList

public java.util.List subList(int from,
                              int to)
Specified by:
subList in interface java.util.List


Copyright © 2000-2003 Ian F. Darwin. See license.html for usage license.