|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectaQute.lib.collections.SortedList<T>
T - public class SortedList<T>
An immutbale list that sorts objects by their natural order or through a comparator. It has convenient methods/constructors to create it from collections and iterators. Why not maintain the lists in their sorted form? Well, TreeMaps are quite expensive ... I once profiled bnd and was shocked how much memory the Jar class took due to the TreeMaps. I could not easily change it unfortunately. The other reason is that Parameters uses a LinkedHashMap because the preferred order should be the declaration order. However, sometimes you need to sort the keys by name. Last, and most important reason, is that sometimes you do not know what collection you have or it is not available in a sort ordering (MultiMap for example) ... I found myself sorting these things over and over again and decided to just make an immutable SortedList that is easy to slice and dice
| Constructor Summary | |
|---|---|
SortedList(Collection<? extends Comparable<?>> x)
|
|
SortedList(Collection<? extends T> x,
int start,
int end,
Comparator<T> cmp)
|
|
SortedList(Collection<T> x,
Comparator<T> cmp)
|
|
SortedList(Comparator<T> cmp,
T... x)
|
|
SortedList(T... x)
|
|
SortedList(T[] x,
int start,
int end,
Comparator<T> comparator2)
|
|
| Method Summary | ||
|---|---|---|
void |
add(int index,
T element)
Deprecated. |
|
boolean |
add(T e)
|
|
boolean |
addAll(Collection<? extends T> c)
|
|
boolean |
addAll(int index,
Collection<? extends T> c)
Deprecated. |
|
void |
clear()
|
|
Comparator<? super T> |
comparator()
|
|
boolean |
contains(Object o)
|
|
boolean |
containsAll(Collection<?> c)
|
|
static
|
empty()
|
|
boolean |
equals(Object other)
Deprecated. |
|
T |
first()
|
|
static
|
fromIterator(Iterator<T> it)
|
|
static
|
fromIterator(Iterator<T> it,
Comparator<T> cmp)
|
|
T |
get(int index)
|
|
Class<?> |
getType()
|
|
boolean |
hasDuplicates()
|
|
int |
hashCode()
Deprecated. |
|
SortedList<T> |
headSet(T toElement)
|
|
int |
indexOf(Object o)
|
|
boolean |
isEmpty()
|
|
boolean |
isEqual(SortedList<T> list)
|
|
boolean |
isSubSet()
|
|
Iterator<T> |
iterator()
|
|
T |
last()
|
|
int |
lastIndexOf(Object o)
|
|
ListIterator<T> |
listIterator()
|
|
ListIterator<T> |
listIterator(int index)
|
|
T |
remove(int index)
Deprecated. |
|
boolean |
remove(Object o)
|
|
boolean |
removeAll(Collection<?> c)
|
|
boolean |
retainAll(Collection<?> c)
|
|
T |
set(int index,
T element)
Deprecated. |
|
void |
setType(Class<?> type)
|
|
int |
size()
|
|
SortedList<T> |
subList(int fromIndex,
int toIndex)
|
|
SortedList<T> |
subSet(T fromElement,
T toElement)
|
|
SortedSet<T> |
tailSet(T fromElement)
|
|
Object[] |
toArray()
|
|
|
toArray(X[] a)
|
|
String |
toString()
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public SortedList(Collection<? extends Comparable<?>> x)
public SortedList(Collection<T> x,
Comparator<T> cmp)
public SortedList(T... x)
public SortedList(Comparator<T> cmp,
T... x)
public SortedList(T[] x,
int start,
int end,
Comparator<T> comparator2)
public SortedList(Collection<? extends T> x,
int start,
int end,
Comparator<T> cmp)
| Method Detail |
|---|
public int size()
size in interface Collection<T>size in interface List<T>size in interface Set<T>public boolean isEmpty()
isEmpty in interface Collection<T>isEmpty in interface List<T>isEmpty in interface Set<T>public boolean contains(Object o)
contains in interface Collection<T>contains in interface List<T>contains in interface Set<T>public Iterator<T> iterator()
iterator in interface Iterable<T>iterator in interface Collection<T>iterator in interface List<T>iterator in interface Set<T>public Object[] toArray()
toArray in interface Collection<T>toArray in interface List<T>toArray in interface Set<T>public <X> X[] toArray(X[] a)
toArray in interface Collection<T>toArray in interface List<T>toArray in interface Set<T>public boolean add(T e)
add in interface Collection<T>add in interface List<T>add in interface Set<T>public boolean remove(Object o)
remove in interface Collection<T>remove in interface List<T>remove in interface Set<T>public boolean containsAll(Collection<?> c)
containsAll in interface Collection<T>containsAll in interface List<T>containsAll in interface Set<T>public boolean addAll(Collection<? extends T> c)
addAll in interface Collection<T>addAll in interface List<T>addAll in interface Set<T>public boolean retainAll(Collection<?> c)
retainAll in interface Collection<T>retainAll in interface List<T>retainAll in interface Set<T>public boolean removeAll(Collection<?> c)
removeAll in interface Collection<T>removeAll in interface List<T>removeAll in interface Set<T>public void clear()
clear in interface Collection<T>clear in interface List<T>clear in interface Set<T>public Comparator<? super T> comparator()
comparator in interface SortedSet<T>public boolean isSubSet()
public SortedList<T> subSet(T fromElement,
T toElement)
subSet in interface SortedSet<T>public int indexOf(Object o)
indexOf in interface List<T>public int lastIndexOf(Object o)
lastIndexOf in interface List<T>public SortedSet<T> tailSet(T fromElement)
tailSet in interface SortedSet<T>public SortedList<T> headSet(T toElement)
headSet in interface SortedSet<T>public T first()
first in interface SortedSet<T>public T last()
last in interface SortedSet<T>
@Deprecated
public boolean addAll(int index,
Collection<? extends T> c)
addAll in interface List<T>public T get(int index)
get in interface List<T>
@Deprecated
public T set(int index,
T element)
set in interface List<T>
@Deprecated
public void add(int index,
T element)
add in interface List<T>@Deprecated public T remove(int index)
remove in interface List<T>public ListIterator<T> listIterator()
listIterator in interface List<T>public ListIterator<T> listIterator(int index)
listIterator in interface List<T>
public SortedList<T> subList(int fromIndex,
int toIndex)
subList in interface List<T>@Deprecated public boolean equals(Object other)
equals in interface Collection<T>equals in interface List<T>equals in interface Set<T>equals in class Object@Deprecated public int hashCode()
hashCode in interface Collection<T>hashCode in interface List<T>hashCode in interface Set<T>hashCode in class Objectpublic boolean isEqual(SortedList<T> list)
public Class<?> getType()
public void setType(Class<?> type)
public String toString()
toString in class Objectpublic boolean hasDuplicates()
public static <T extends Comparable<?>> SortedList<T> fromIterator(Iterator<T> it)
public static <T> SortedList<T> fromIterator(Iterator<T> it,
Comparator<T> cmp)
public static <T> SortedSet<T> empty()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||