|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.cilib.container.SortedList<E>
E
- The Comparable type.public class SortedList<E extends Comparable<? super E>>
A collection that always provides a list of elements that is sorted. The ordering is
specified by the provided Comparator instance. If no comparator is
provided, the natural ordering of the type E
will be used.
Constructor Summary | |
---|---|
SortedList()
Create a new instance of SortedList without a Comparator defined. |
|
SortedList(Comparator<E> comparator)
Create a new instance of SortedList with the provided Comparator. |
|
SortedList(SortedList<E> copy)
Create a copy of the provided instance. |
Method Summary | ||
---|---|---|
boolean |
add(E e)
Add the provided element to the list. |
|
void |
add(int index,
E element)
Add element to the list at index index . |
|
boolean |
addAll(Collection<? extends E> c)
|
|
boolean |
addAll(int index,
Collection<? extends E> c)
Insert the proveded collection to the list at index . |
|
void |
clear()
|
|
boolean |
contains(Object o)
Returns true if this list contains the specified element. |
|
boolean |
containsAll(Collection<?> c)
|
|
E |
get(int index)
|
|
SortedList<E> |
getClone()
Create a cloned copy of the current object and return it. |
|
Comparator<E> |
getComparator()
Get the current Comparator instance. |
|
int |
indexOf(Object o)
|
|
boolean |
isEmpty()
Returns true if this list contains no elements. |
|
Iterator<E> |
iterator()
Returns an iterator over this sequence in proper order. |
|
int |
lastIndexOf(Object o)
|
|
ListIterator<E> |
listIterator()
|
|
ListIterator<E> |
listIterator(int index)
|
|
E |
remove(int index)
|
|
boolean |
remove(Object o)
|
|
boolean |
removeAll(Collection<?> c)
|
|
boolean |
retainAll(Collection<?> c)
|
|
E |
set(int index,
E element)
Replace the current element located at index with element . |
|
void |
setComparator(Comparator<E> comparator)
Set the Comparator to use. |
|
int |
size()
Determine the size of the current list. |
|
List<E> |
subList(int fromIndex,
int toIndex)
|
|
Object[] |
toArray()
Return a new array containg the elements of this list. |
|
|
toArray(T[] a)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
equals, hashCode |
Constructor Detail |
---|
public SortedList()
public SortedList(Comparator<E> comparator)
comparator
- The Comparator to use.public SortedList(SortedList<E> copy)
copy
- The instance to copy.Method Detail |
---|
public SortedList<E> getClone()
getClone
in interface Cloneable
Object.clone()
public int size()
size
in interface Collection<E extends Comparable<? super E>>
size
in interface List<E extends Comparable<? super E>>
public boolean isEmpty()
true
if this list contains no elements.
isEmpty
in interface Collection<E extends Comparable<? super E>>
isEmpty
in interface List<E extends Comparable<? super E>>
true
if this list contains no elements.public boolean contains(Object o)
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))
.
contains
in interface Collection<E extends Comparable<? super E>>
contains
in interface List<E extends Comparable<? super E>>
o
- element whose presence is to be tested.
true
if this list contains the specified element.public Iterator<E> iterator()
iterator
in interface Iterable<E extends Comparable<? super E>>
iterator
in interface Collection<E extends Comparable<? super E>>
iterator
in interface List<E extends Comparable<? super E>>
public Object[] toArray()
toArray
in interface Collection<E extends Comparable<? super E>>
toArray
in interface List<E extends Comparable<? super E>>
public <T> T[] toArray(T[] a)
toArray
in interface Collection<E extends Comparable<? super E>>
toArray
in interface List<E extends Comparable<? super E>>
public boolean add(E e)
Comparator
.
The insertion is determined by first performing a binary search to
determine the location of the insert and then, finally adding the element.
add
in interface Collection<E extends Comparable<? super E>>
add
in interface List<E extends Comparable<? super E>>
e
- The object to add to the list.
true
if the addition was successful.public boolean remove(Object o)
remove
in interface Collection<E extends Comparable<? super E>>
remove
in interface List<E extends Comparable<? super E>>
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<E extends Comparable<? super E>>
containsAll
in interface List<E extends Comparable<? super E>>
public boolean addAll(Collection<? extends E> c)
addAll
in interface Collection<E extends Comparable<? super E>>
addAll
in interface List<E extends Comparable<? super E>>
public boolean addAll(int index, Collection<? extends E> c)
index
. This operation
is not guaranteed and to ensure that the list remains sorted, the list
is tested after addition and reordered, if needed.
addAll
in interface List<E extends Comparable<? super E>>
index
- The index to attempt the addition.c
- The collection to add.
true
if the operation was successful.public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<E extends Comparable<? super E>>
removeAll
in interface List<E extends Comparable<? super E>>
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<E extends Comparable<? super E>>
retainAll
in interface List<E extends Comparable<? super E>>
public void clear()
clear
in interface Collection<E extends Comparable<? super E>>
clear
in interface List<E extends Comparable<? super E>>
public E get(int index)
get
in interface List<E extends Comparable<? super E>>
public E set(int index, E element)
index
with element
.
Even though the element is replaced, there is no guarantee that the order
or location of the new element will be at index
. After the replacement
the order of the list is shuffled to ensure that the sorted nature of the
list is maintained.
set
in interface List<E extends Comparable<? super E>>
index
- The current location of the element to replace.element
- The element to replace the element at index index
.
public void add(int index, E element)
element
to the list at index index
. This action is a
best effort. There is no guarantee that the addition of the element at
index
will perserve the list's ordering. As a result the list
order is verified after addition.
add
in interface List<E extends Comparable<? super E>>
index
- The position in the list to attempt the addition.element
- The element to add.public E remove(int index)
remove
in interface List<E extends Comparable<? super E>>
public int indexOf(Object o)
indexOf
in interface List<E extends Comparable<? super E>>
public int lastIndexOf(Object o)
lastIndexOf
in interface List<E extends Comparable<? super E>>
public ListIterator<E> listIterator()
listIterator
in interface List<E extends Comparable<? super E>>
public ListIterator<E> listIterator(int index)
listIterator
in interface List<E extends Comparable<? super E>>
public List<E> subList(int fromIndex, int toIndex)
subList
in interface List<E extends Comparable<? super E>>
public Comparator<E> getComparator()
public void setComparator(Comparator<E> comparator)
comparator
- The comparator to set.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |