public class OrderedCollection<E>
extends java.lang.Object
implements java.util.Collection<E>
Constructor and Description |
---|
OrderedCollection()
Initialize the new instance with default values.
|
OrderedCollection(int initialCapacity)
Initialize the new instance with a given initial capacity.
|
OrderedCollection(java.util.List<E> list)
Initialize the new instance with default values.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(E o)
Appends the specified element to the end of this list.
|
void |
add(int index,
E element)
Inserts the specified element at the specified position in this list.
|
boolean |
addAll(java.util.Collection<? extends E> 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
(optional operation).
|
boolean |
addAll(int index,
java.util.Collection<? extends E> c)
Inserts all of the elements in the specified collection into this list at the
specified position (optional operation).
|
E |
at(int index)
Returns the element at the specified position in this list.
|
E |
atPut(int index,
E element)
Replaces the element at the specified position in this list with
the specified element.
|
void |
clear()
Removes all of the elements from this list.
|
boolean |
contains(java.lang.Object o)
Returns true if this list contains the specified element.
|
boolean |
containsAll(java.util.Collection<?> c)
Returns true if this list contains all of the elements of the specified collection.
|
E |
detect_(Block1<E,java.lang.Boolean> aBlock)
Loop over all the receiver's elements and call the given blocks eval() - method
for each.
|
<TResult> TResult |
do_(Block1<E,TResult> aBlock)
Loop over all the receiver's elements and call the given blocks eval() - method
for each.
|
boolean |
equals(java.lang.Object o)
Compares the specified object with this list for equality.
|
E |
first()
Returns the first element of the receiver.
|
E |
get(int index)
Returns the element at the specified position in this list.
|
protected java.util.List<E> |
getBasicCollection() |
int |
hashCode()
Returns the hash code value for this list.
|
int |
indexOf(E o)
Returns the index in this list of the first occurrence of the specified element,
or 0 if this list does not contain this element.
|
boolean |
isEmpty()
Returns true if this list contains no elements.
|
java.util.Iterator<E> |
iterator()
Returns an iterator over the elements in this list in proper sequence.
|
E |
last()
Returns the last element of the receiver.
|
int |
lastIndexOf(E o)
Returns the index in this list of the last occurrence of the specified element,
or 0 if this list does not contain this element.
|
java.util.ListIterator<E> |
listIterator()
Returns a list iterator of the elements in this list (in proper sequence).
|
java.util.ListIterator<E> |
listIterator(int index)
Returns a list iterator of the elements in this list (in proper sequence),
starting at the specified position in this list.
|
E |
remove(int index)
Removes the element at the specified position in this list.
|
boolean |
remove(java.lang.Object o)
Removes the first occurrence in this list of the specified element
(optional operation).
|
boolean |
removeAll(java.util.Collection<?> c)
Removes from this list all the elements that are contained in the specified
collection.
|
boolean |
retainAll(java.util.Collection<?> c)
Retains only the elements in this list that are contained in the specified
collection.
|
E |
set(int index,
E element)
Replaces the element at the specified position in this list with
the specified element.
|
protected void |
setBasicCollection(java.util.List<E> newValue) |
int |
size()
Returns the number of elements in this list.
|
java.util.List<E> |
subList(int fromIndex,
int toIndex)
Returns a view of the portion of this list between the specified
fromIndex, inclusive, and toIndex, inclusive.
|
java.lang.Object[] |
toArray()
Returns an array containing all of the elements in this list in proper sequence.
|
<T> T[] |
toArray(T[] a)
Returns an array containing all of the elements in this list in proper sequence;
the runtime type of the returned array is that of the specified array.
|
java.util.Vector<E> |
toVector()
Returns a copy of this collection in a Vector
|
public OrderedCollection()
public OrderedCollection(int initialCapacity)
public OrderedCollection(java.util.List<E> list)
public int size()
size
in interface java.util.Collection<E>
public boolean isEmpty()
isEmpty
in interface java.util.Collection<E>
public boolean contains(java.lang.Object o)
contains
in interface java.util.Collection<E>
o
- - element whose presence in this list is to be tested.public java.util.Iterator<E> iterator()
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection<E>
public <T> T[] toArray(T[] a) throws java.lang.ArrayStoreException
toArray
in interface java.util.Collection<E>
a
- - the array into which the elements of this list are to be stored,
if it is big enough; otherwise, a new array of the same runtime type
is allocated for this purpose.java.lang.ArrayStoreException
- - if the runtime type of the specified array is not
a supertype of the runtime type of every element in this list.public boolean add(E o)
add
in interface java.util.Collection<E>
o
- - element to be appended to this list.public boolean remove(java.lang.Object o)
remove
in interface java.util.Collection<E>
o
- - element to be removed from this list, if present.public boolean containsAll(java.util.Collection<?> c)
containsAll
in interface java.util.Collection<E>
c
- - collection to be checked for containment in this list.public boolean addAll(java.util.Collection<? extends E> c)
addAll
in interface java.util.Collection<E>
c
- - collection whose elements are to be added to this list.public boolean addAll(int index, java.util.Collection<? extends E> c) throws java.lang.IndexOutOfBoundsException
index
- - index at which to insert first element from the specified collection.
( 1 <= index <= size() )c
- - elements to be inserted into this list.java.lang.IndexOutOfBoundsException
- - if the index is out of range
(index < 1 || index > size()).public boolean removeAll(java.util.Collection<?> c)
removeAll
in interface java.util.Collection<E>
c
- - collection that defines which elements will be removed from this list.public boolean retainAll(java.util.Collection<?> c)
retainAll
in interface java.util.Collection<E>
c
- - collection that defines which elements this set will retain.public void clear()
clear
in interface java.util.Collection<E>
public boolean equals(java.lang.Object o)
equals
in interface java.util.Collection<E>
equals
in class java.lang.Object
o
- - the object to be compared for equality with this list.public int hashCode()
hashCode
in interface java.util.Collection<E>
hashCode
in class java.lang.Object
public E get(int index) throws java.lang.IndexOutOfBoundsException
index
- - index of element to return. ( 1 <= index <= size() )java.lang.IndexOutOfBoundsException
- - if the index is out of range
(index < 1 || index > size()).public E set(int index, E element) throws java.lang.IndexOutOfBoundsException
index
- - index of element to replace. ( 1 <= index <= size() )element
- - element to be stored at the specified position.java.lang.IndexOutOfBoundsException
- - if the index is out of range
(index < 1 || index > size()).public void add(int index, E element) throws java.lang.IndexOutOfBoundsException
index
- - index at which the specified element is to be inserted.element
- - element to be inserted.java.lang.IndexOutOfBoundsException
- - if the index is out of range
(index < 1 || index > size()).public E remove(int index)
index
- - the index of the element to removed.java.lang.IndexOutOfBoundsException
- - if the index is out of range
(index < 1 || index > size()).public int indexOf(E o)
o
- - element to search for.public int lastIndexOf(E o)
o
- - element to search for.public java.util.ListIterator<E> listIterator()
public java.util.ListIterator<E> listIterator(int index) throws java.lang.IndexOutOfBoundsException
index
- - index of first element to be returned from the list iterator
(by a call to the next method).java.lang.IndexOutOfBoundsException
- - if the index is out of range
(index < 1 || index > size()).public java.util.List<E> subList(int fromIndex, int toIndex) throws java.lang.IndexOutOfBoundsException
fromIndex
- - low endpoint (inclusive) of the subList.toIndex
- - high endpoint (inclusive) of the subList.java.lang.IndexOutOfBoundsException
- - for an illegal endpoint index value
(fromIndex < 1 || toIndex > size() || fromIndex > toIndex).public E at(int index) throws java.lang.IndexOutOfBoundsException
index
- - index of element to return. ( 1 <= index <= size() )java.lang.IndexOutOfBoundsException
- - if the index is out of range
(index < 1 || index > size()).public E atPut(int index, E element) throws java.lang.IndexOutOfBoundsException
index
- - index of element to replace. ( 1 <= index <= size() )element
- - element to be stored at the specified position.java.lang.IndexOutOfBoundsException
- - if the index is out of range
(index < 1 || index > size()).public java.util.Vector<E> toVector()
Vector
public <TResult> TResult do_(Block1<E,TResult> aBlock)
aBlock
- The block to evaluate for each element.public E detect_(Block1<E,java.lang.Boolean> aBlock)
aBlock
- The block to evaluate for each element.public E first()
public E last()
protected java.util.List<E> getBasicCollection()
protected void setBasicCollection(java.util.List<E> newValue)