|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exolab.adaptx.util.List
public class List
This is my implementation of the JDK 1.2 List interface.
I wrote this because I want people using 1.1.x to be able
to use my apps, but I don't want to use a "synchronized" Vector.
I also wanted to get a start in moving my source to JDK 1.2
I use the implementation of the hashCode method that is listed
in the JDK 1.2 API, so this List can be compared correctly to actual
JDK 1.2 lists using the equals method.
Note: This is not a complete implementation yet,
None of the methods that take a Collection have been imlplemented.
List
,
Collection
Constructor Summary | |
---|---|
List()
Creates a new BasicSet with the default Size |
|
List(int size)
|
Method Summary | |
---|---|
boolean |
add(int index,
java.lang.Object obj)
Adds the specified Object to the list at the specified index |
boolean |
add(java.lang.Object obj)
Adds the specified Object to the list |
void |
clear()
Removes all elements from the list |
java.lang.Object |
clone()
|
boolean |
contains(java.lang.Object obj)
Returns true if the specified element is contained in the list. |
boolean |
equals(java.lang.Object obj)
Compares the specified object with this list for equality. |
java.lang.Object |
get(int index)
Returns the element at the specified position in this list. |
int |
hashCode()
As defined by the JDK 1.2 API spec: Returns the hash code value for this list. |
int |
indexOf(java.lang.Object obj)
Returns the index of the first occurrence of the specified element, or -1 if the element is not contained in the List |
boolean |
isEmpty()
Returns true if there are no elements in the List. |
int |
lastIndexOf(java.lang.Object obj)
Returns the index of the last occurrence of the specified element, or -1 if the element is not contained in the List |
java.lang.Object |
remove(int index)
Removes the element at the specified index from the List |
boolean |
remove(java.lang.Object obj)
Removes the first occurrence of the specified element from the List |
java.lang.Object |
set(int index,
java.lang.Object element)
Replaces the element at the specified position in this list with the specified element. |
int |
size()
Returns the number of elements in the List |
List |
subList(int fromIndex,
int toIndex)
Returns a new List which contains elements from a given section of this list. |
java.lang.Object[] |
toArray()
Returns an array containing all of the elements in this list in proper sequence. |
java.lang.Object[] |
toArray(java.lang.Object[] dst)
Returns an array containing all of the elements in this list in proper sequence. |
void |
trimToSize()
Reduces the capacity of the internal buffer to the current size freeing up unused memory. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public List()
public List(int size)
Method Detail |
---|
public boolean add(java.lang.Object obj)
obj
- the Object to add to the list
public boolean add(int index, java.lang.Object obj) throws java.lang.IndexOutOfBoundsException
obj
- the Object to add to the list
java.lang.IndexOutOfBoundsException
public void clear()
public java.lang.Object clone()
clone
in class java.lang.Object
public boolean contains(java.lang.Object obj)
obj
- the element to search the list for
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.Object get(int index) throws java.lang.IndexOutOfBoundsException
index
- the position of the element to return
java.lang.IndexOutOfBoundsException
public int hashCode()
hashCode = 1;
Iterator i = list.iterator();
while (i.hasNext()) {
Object obj = i.next();
hashCode = 31*hashCode + (obj==null ? 0 : obj.hashCode());
}
hashCode
in class java.lang.Object
public int indexOf(java.lang.Object obj)
obj
- the Object to get the index forpublic boolean isEmpty()
public int lastIndexOf(java.lang.Object obj)
obj
- the Object to get the last index forpublic java.lang.Object remove(int index)
index
- the position in the list tp remove the element from
public boolean remove(java.lang.Object obj)
obj
- the Object to remove from the List
public void trimToSize()
public java.lang.Object set(int index, java.lang.Object element) throws java.lang.IndexOutOfBoundsException
index
- the position in the list to place the element atelement
- the element to add to the list
java.lang.IndexOutOfBoundsException
public int size()
public List subList(int fromIndex, int toIndex)
fromIndex
- the start index (inclusize) of elements
to add to the new listtoIndex
- the end index (exclusive)of the elements to add
to the new list
java.lang.IndexOutOfBoundsException
- for invalid index valuespublic java.lang.Object[] toArray()
public java.lang.Object[] toArray(java.lang.Object[] dst)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |