de.erichseifert.gral.util
Class SortedList<T extends Comparable<T>>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<T>
de.erichseifert.gral.util.SortedList<T>
- Type Parameters:
T
- Data type of stored elements.
- All Implemented Interfaces:
- Iterable<T>, Collection<T>, List<T>
public class SortedList<T extends Comparable<T>>
- extends AbstractList<T>
Resizable implementation of the List interface that automatically sorts all
values. It implements the methods get
, size
,
add
, and size
. The stored elements must implement
the interface Comparable
.
Constructor Summary |
SortedList()
Constructs an empty list with an initial capacity of ten. |
SortedList(Collection<? extends T> c)
Constructs a list containing the elements of the specified collection. |
SortedList(int initialCapacity)
Constructs an empty list with the specified initial capacity. |
Methods inherited from class java.util.AbstractList |
add, addAll, clear, equals, hashCode, iterator, lastIndexOf, listIterator, listIterator, set, subList |
SortedList
public SortedList(int initialCapacity)
- Constructs an empty list with the specified initial capacity.
- Parameters:
initialCapacity
- Initial capacity of the list.
SortedList
public SortedList(Collection<? extends T> c)
- Constructs a list containing the elements of the specified collection.
- Parameters:
c
- Collection whose elements are to be added.
SortedList
public SortedList()
- Constructs an empty list with an initial capacity of ten.
get
public T get(int index)
- Specified by:
get
in interface List<T extends Comparable<T>>
- Specified by:
get
in class AbstractList<T extends Comparable<T>>
size
public int size()
- Specified by:
size
in interface Collection<T extends Comparable<T>>
- Specified by:
size
in interface List<T extends Comparable<T>>
- Specified by:
size
in class AbstractCollection<T extends Comparable<T>>
add
public boolean add(T e)
- Specified by:
add
in interface Collection<T extends Comparable<T>>
- Specified by:
add
in interface List<T extends Comparable<T>>
- Overrides:
add
in class AbstractList<T extends Comparable<T>>
remove
public T remove(int index)
- Specified by:
remove
in interface List<T extends Comparable<T>>
- Overrides:
remove
in class AbstractList<T extends Comparable<T>>
indexOf
public int indexOf(Object o)
- Specified by:
indexOf
in interface List<T extends Comparable<T>>
- Overrides:
indexOf
in class AbstractList<T extends Comparable<T>>
Copyright © 2009-2010. All Rights Reserved.