csli.util.collections
Class SortedList<E extends Comparable<? super E>>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
csli.util.collections.SortedList<E>
- Type Parameters:
E -
- All Implemented Interfaces:
- Iterable<E>, Collection<E>, List<E>, Set<E>, SortedSet<E>
public class SortedList<E extends Comparable<? super E>>
- extends AbstractList<E>
- implements List<E>, SortedSet<E>
Red-black binary search tree. Basically I needed a SortedSet that was less
set-like and more list-like. Main difference from SortedSet: allows multiple
elements that compare as equal, and random access
- Author:
- jefe
| Methods inherited from class java.util.AbstractList |
add, addAll, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList |
| Methods inherited from interface java.util.List |
add, addAll, addAll, containsAll, equals, hashCode, indexOf, isEmpty, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, subList, toArray, toArray |
SortedList
public SortedList()
- Constructors.
SortedList
public SortedList(Collection<? extends E> elements)
SortedList
public SortedList(Comparator<? super E> comparator)
get
public E get(int index)
- Specified by:
get in interface List<E extends Comparable<? super E>>- Specified by:
get in class AbstractList<E extends Comparable<? super E>>
add
public boolean add(E o)
- Specified by:
add in interface Collection<E extends Comparable<? super E>>- Specified by:
add in interface List<E extends Comparable<? super E>>- Specified by:
add in interface Set<E extends Comparable<? super E>>- Overrides:
add in class AbstractList<E extends Comparable<? super E>>
contains
public boolean contains(Object o)
throws ClassCastException
- Specified by:
contains in interface Collection<E extends Comparable<? super E>>- Specified by:
contains in interface List<E extends Comparable<? super E>>- Specified by:
contains in interface Set<E extends Comparable<? super E>>- Overrides:
contains in class AbstractCollection<E extends Comparable<? super E>>
- Throws:
ClassCastException - if parameter is not of type E.
compare
protected int compare(E x,
E y)
clear
public void clear()
- Specified by:
clear in interface Collection<E extends Comparable<? super E>>- Specified by:
clear in interface List<E extends Comparable<? super E>>- Specified by:
clear in interface Set<E extends Comparable<? super E>>- Overrides:
clear in class AbstractList<E extends Comparable<? super E>>
size
public int size()
- Specified by:
size in interface Collection<E extends Comparable<? super E>>- Specified by:
size in interface List<E extends Comparable<? super E>>- Specified by:
size in interface Set<E extends Comparable<? super E>>- Specified by:
size in class AbstractCollection<E extends Comparable<? super E>>
first
public E first()
- Specified by:
first in interface SortedSet<E extends Comparable<? super E>>
last
public E last()
- Specified by:
last in interface SortedSet<E extends Comparable<? super E>>
middle
public E middle()
comparator
public Comparator<? super E> comparator()
- Specified by:
comparator in interface SortedSet<E extends Comparable<? super E>>
headSet
public SortedList<E> headSet(E toElement)
- Specified by:
headSet in interface SortedSet<E extends Comparable<? super E>>
tailSet
public SortedList<E> tailSet(E fromElement)
- Specified by:
tailSet in interface SortedSet<E extends Comparable<? super E>>
subSet
public SortedSet<E> subSet(E fromElement,
E toElement)
- Specified by:
subSet in interface SortedSet<E extends Comparable<? super E>>
iterator
public Iterator<E> iterator()
- Specified by:
iterator in interface Iterable<E extends Comparable<? super E>>- Specified by:
iterator in interface Collection<E extends Comparable<? super E>>- Specified by:
iterator in interface List<E extends Comparable<? super E>>- Specified by:
iterator in interface Set<E extends Comparable<? super E>>- Overrides:
iterator in class AbstractList<E extends Comparable<? super E>>
main
public static void main(String[] args)