Interface COM.odi.util.List
- public interface List
- extends Collection
This is the COM.odi.util version of java.util.List,
which will be generally available in the JDK 1.2. At that
time, COM.odi.util.List will be obsoleted, in favor
of the interface in java.util.List.
Additional information about lists
is in the user guide.
-
add(int, Object)
- Inserts the specified element at the specified position in this
List (optional operation).
-
add(Object)
- Appends the specified element to the end of this List (optional
operation).
-
addAll(Collection)
- Appends all of the elements in the specified Collection to the
end of this this List, in the order that they are returned by
the specified Collection's Iterator (optional operation).
-
addAll(int, Collection)
- Inserts all of the elements in in the specified Collection into
this List at the specified position (optional operation).
-
clear()
- Removes all of the elements from this List (optional
operation).
-
contains(Object)
- Returns true if this List contains the specified element.
-
containsAll(Collection)
- Returns true if this List contains all of the elements of the
specified Collection.
-
equals(Object)
- Compares the specified Object with this List for equality.
-
get(int)
- Returns the element at the specified position in this List.
-
hashCode()
- Returns the hash code value for this List.
-
indexOf(Object)
- Returns the index in this List of the first occurence of the
specified element, or -1 if the List does not contain this
element.
-
indexOf(Object, int)
- Returns the index in this List of the first occurence of the
specified element at or after the specified position, or -1 if
the element is not found.
-
isEmpty()
- Returns true if this List contains no elements.
-
iterator()
- Returns an Iterator over the elements in this List in proper
sequence.
-
lastIndexOf(Object)
- Returns the index in this List of the last occurence of the
specified element, or -1 if the List does not contain this
element.
-
lastIndexOf(Object, int)
- Returns the index in this List of the last occurence of the
specified element at or before the specified position, or -1 if
the List does not contain this element.
-
listIterator()
- Returns a ListIterator of the elements in this List (in proper
sequence).
-
listIterator(int)
- Returns a ListIterator of the elements in this List (in proper
sequence), starting at the specified position in the List.
-
remove(int)
- Removes the element at the specified position in this List
(optional operation).
-
remove(Object)
- Removes the first occurence of the specified element in this
List (optional operation).
-
removeAll(Collection)
- Removes from this List all of its elements that are contained
in the specified Collection (optional operation).
-
removeRange(int, int)
- Removes from this List all of the elements whose index is
between fromIndex, inclusive and toIndex, exclusive (optional
operation).
-
retainAll(Collection)
- Retains only the elements in this List that are contained in
the specified Collection (optional operation).
-
set(int, Object)
- Replaces the element at the specified position in this List
with the specified element (optional operation).
-
size()
- Returns the number of elements in this List.
-
toArray()
- Returns an array containing all of the elements in this List.
size
public abstract int size()
- Returns the number of elements in this List.
isEmpty
public abstract boolean isEmpty()
- Returns true if this List contains no elements.
contains
public abstract boolean contains(Object o)
- Returns true if this List contains the specified element. More
formally, returns true if and only if this List contains at
least one element
e
such that (o==null ?
e==null : o.equals(e))
.
- Parameters:
- o - element whose presence in this List is to be tested.
iterator
public abstract Iterator iterator()
- Returns an Iterator over the elements in this List in proper
sequence.
toArray
public abstract Object[] toArray()
- Returns an array containing all of the elements in this List.
Obeys the general contract of Collection.toArray.
add
public abstract boolean add(Object o)
- Appends the specified element to the end of this List (optional
operation).
- Parameters:
- o - element to be appended to this List.
- Returns:
- true (as per the general contract of Collection.add).
- Throws: UnsupportedOperationException
- add is not supported
by this Set.
- Throws: ClassCastException
- class of the specified element
prevents it from being added to this Set.
- Throws: IllegalArgumentException
- some aspect of this element prevents
it from being added to this Collection.
remove
public abstract boolean remove(Object o)
- Removes the first occurence of the specified element in this
List (optional operation). If the List does not contain the
element, it is unchanged. More formally, removes the element
with the lowest index i such that
(o==null ? get(i)==null
: o.equals(get(i)))
(if such an element exists).
- Parameters:
- o - element to be removed from this List, if present.
- Returns:
- true if the List contained the specified element.
- Throws: UnsupportedOperationException
- remove is not supported
by this List.
containsAll
public abstract boolean containsAll(Collection c)
- Returns true if this List contains all of the elements of the
specified Collection.
addAll
public abstract boolean addAll(Collection c)
- Appends all of the elements in the specified Collection to the
end of this 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.)
- Returns:
- true if this List changed as a result of the call.
- Throws: UnsupportedOperationException
- addAll is not supported
by this List.
- Throws: ClassCastException
- class of an element in the specified
Collection prevents it from being added to this List.
- Throws: IllegalArgumentException
- some aspect of an element in the
specified Collection prevents it from being added to this
List.
removeAll
public abstract boolean removeAll(Collection c)
- Removes from this List all of its elements that are contained
in the specified Collection (optional operation).
- Returns:
- true if this List changed as a result of the call.
- Throws: UnsupportedOperationException
- removeAll is not supported
by this List.
retainAll
public abstract boolean retainAll(Collection c)
- Retains only the elements in this List that are contained in
the specified Collection (optional operation). In other words,
removes from this List all of its elements that are not
contained in the specified Collection.
- Returns:
- true if this List changed as a result of the call.
- Throws: UnsupportedOperationException
- retainAll is not supported
by this List.
clear
public abstract void clear()
- Removes all of the elements from this List (optional
operation). The List will be empty after this call returns
(unless it throws an exception).
- Throws: UnsupportedOperationException
- clear is not supported
by this List.
equals
public abstract boolean equals(Object o)
- Compares the specified Object with this List for equality.
Returns true if and only if the specified Object is also a
List, both Lists have the same size, and all corresponding
pairs of elements in the two Lists are equal. (Two
elements
e1
and e2
are equal
if (e1==null ? e2==null : e1.equals(e2))
.) In
other words, two Lists are defined to be equal if they contain
the same elements in the same order.
- Parameters:
- o - the Object to be compared for equality with this List.
- Returns:
- true if the specified Object is equal to this List.
- Overrides:
- equals in class Object
hashCode
public abstract int hashCode()
- Returns the hash code value for this List. The hash code of a
List is defined to be the result of the following calculation:
hashCode = 0;
Iterator i = list.iterator();
while (i.hasNext()) {
Object obj = i.next();
hashCode = 31*hashCode + (obj==null ? 0 : obj.hashCode());
}
This ensures that list1.equals(list2)
implies that
list1.hashCode()==list2.hashCode()
for any two Lists,
list1
and list2
, as required by the general
contract of Object.hashCode.
- Overrides:
- hashCode in class Object
get
public abstract Object get(int index)
- Returns the element at the specified position in this List.
- Parameters:
- index - index of element to return.
- Throws: IndexOutOfBoundsException
- index is out of range (index
< 0 || index > = size()).
set
public abstract Object set(int index,
Object element)
- Replaces the element at the specified position in this List
with the specified element (optional operation).
- Parameters:
- index - index of element to replace.
- element - element to be stored at the specified position.
- Returns:
- the element previously at the specified position.
- Throws: UnsupportedOperationException
- set is not supported
by this List.
- Throws: ClassCastException
- class of the specified element
prevents it from being added to this List.
- Throws: IllegalArgumentException
- some aspect of the specified
element prevents it from being added to this List.
- Throws: IndexOutOfBoundsException
- index out of range
(index < 0 || index >= size()).
add
public abstract void add(int index,
Object element)
- Inserts the specified element at the specified position in this
List (optional operation). Shifts the element currently at
that position (if any) and any subsequent elements to the right
(adds one to their indices).
- Parameters:
- index - index at which the specified element is to be inserted.
- element - element to be inserted.
- Throws: UnsupportedOperationException
- add is not supported
by this List.
- Throws: ClassCastException
- class of the specified element
prevents it from being added to this List.
- Throws: IllegalArgumentException
- some aspect of the specified
element prevents it from being added to this List.
- Throws: IndexOutOfBoundsException
- index is out of range
(index < 0 || index > size()).
remove
public abstract Object remove(int index)
- Removes the element at the specified position in this List
(optional operation). Shifts any subsequent elements to the
left (subtracts one from their indices). Returns the element
that was removed from the List.
- Parameters:
- index - the index of the element to removed.
- Returns:
- the element previously at the specified position.
- Throws: UnsupportedOperationException
- remove is not supported
by this List.
- Throws: IndexOutOfBoundsException
- index out of range (index
< 0 || index > = size()).
indexOf
public abstract int indexOf(Object o)
- Returns the index in this List of the first occurence of the
specified element, or -1 if the List does not contain this
element. More formally, returns the lowest index i such that
(o==null ? get(i)==null : o.equals(get(i)))
, or -1
if there is no such index.
- Parameters:
- o - element to search for.
indexOf
public abstract int indexOf(Object o,
int index)
- Returns the index in this List of the first occurence of the
specified element at or after the specified position, or -1 if
the element is not found. More formally, returns the lowest
index i >= index such that
(o==null ? get(i)==null :
o.equals(get(i)))
, or -1 if there is no such index.
- Parameters:
- o - element to search for.
- index - initial position to search for the specified element.
- Throws: IndexOutOfBoundsException
- index out of range
(index < 0 || index >= size()).
lastIndexOf
public abstract int lastIndexOf(Object o)
- Returns the index in this List of the last occurence of the
specified element, or -1 if the List does not contain this
element. More formally, returns the highest index i such that
(o==null ? get(i)==null : o.equals(get(i)))
, or -1
if there is no such index.
- Parameters:
- o - element to search for.
lastIndexOf
public abstract int lastIndexOf(Object o,
int index)
- Returns the index in this List of the last occurence of the
specified element at or before the specified position, or -1 if
the List does not contain this element. More formally, returns
the highest index i <= index such that
(o==null ?
get(i)==null : o.equals(get(i)))
, or -1 if there is no
such index.
- Parameters:
- o - element to search for.
- index - initial position to search for the specified element.
- Throws: IndexOutOfBoundsException
- index out of range
(index < 0 || index >= size()).
removeRange
public abstract void removeRange(int fromIndex,
int toIndex)
- Removes from this List all of the elements whose index is
between fromIndex, inclusive and toIndex, exclusive (optional
operation). Shifts any succeeding elements to the left
(reduces their index). This call shortens the List by (toIndex
- fromIndex) elements. (If toIndex==fromIndex, this operation
has no effect.)
- Parameters:
- fromIndex - index of first element to be removed.
- toIndex - index after last element to be removed.
- Throws: UnsupportedOperationException
- removeRange is not supported
by this List.
- Throws: IndexOutOfBoundsException
- fromIndex or toIndex out of
range (fromIndex < 0 || fromIndex >= size() || toIndex
> size() || toIndex < fromIndex).
addAll
public abstract boolean addAll(int index,
Collection c)
- Inserts all of the elements in in the specified Collection into
this List at the specified position (optional operation).
Shifts the element currently at that position (if any) and any
subsequent elements to the right (increases their indices).
The new elements will appear in the List in the order that they
are returned by the specified Collection's iterator. 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.)
- Parameters:
- index - index at which to insert first element from the specified
Collection.
- c - elements to be inserted into this List.
- Returns:
- true if this List changed as a result of the call.
- Throws: UnsupportedOperationException
- addAll is not supported
by this List.
- Throws: ClassCastException
- class of one of elements of the specified
Collection prevents it from being added to this List.
- Throws: IllegalArgumentException
- some aspect of one of elements of
the specified Collection prevents it from being added to
this List.
- Throws: IndexOutOfBoundsException
- index out of range (index
< 0 || index > size()).
listIterator
public abstract ListIterator listIterator()
- Returns a ListIterator of the elements in this List (in proper
sequence).
listIterator
public abstract ListIterator listIterator(int index)
- Returns a ListIterator of the elements in this List (in proper
sequence), starting at the specified position in the List. The
specified index indicates the first element that would be
returned by an initial call to nextElement. An initial call to
previousElement would return the element with the specified
index minus one.
- Parameters:
- index - index of first element to be returned from the
ListIterator (by a call to getNext).
- Throws: IndexOutOfBoundsException
- index is out of range
(index < 0 || index > size()).
Copyright © 1996, 1997, 1998 Object Design, Inc. All rights reserved.