public final class SortedList<E> extends TransformationList<E,E>
TransformationList
Modifier and Type | Class and Description |
---|---|
private static class |
SortedList.Element<E> |
private static class |
SortedList.ElementComparator<E> |
Modifier and Type | Field and Description |
---|---|
private ObjectProperty<java.util.Comparator<? super E>> |
comparator
The comparator that denotes the order of this SortedList.
|
private java.util.Comparator<SortedList.Element<E>> |
elementComparator |
private SortHelper |
helper |
private int[] |
perm |
private int |
size |
private SortedList.Element<E>[] |
sorted |
private SortedList.Element<E> |
tempElement |
Constructor and Description |
---|
SortedList(ObservableList<? extends E> source)
Constructs a new unordered SortedList wrapper around the source list.
|
SortedList(ObservableList<? extends E> source,
java.util.Comparator<? super E> comparator)
Creates a new SortedList wrapped around the source list.
|
Modifier and Type | Method and Description |
---|---|
private void |
addRemove(ListChangeListener.Change<? extends E> c) |
ObjectProperty<java.util.Comparator<? super E>> |
comparatorProperty() |
private void |
doSortWithPermutationChange() |
private void |
ensureSize(int size) |
private int |
findPosition(E e) |
E |
get(int index)
Returns the element at the specified position in this list.
|
java.util.Comparator<? super E> |
getComparator() |
int |
getSourceIndex(int index)
Maps the index of this list's element to an index in the direct source list.
|
private void |
insertToMapping(E e,
int idx) |
private void |
removeAllFromMapping() |
private void |
removeFromMapping(int idx,
E e) |
private void |
setAllToMapping(java.util.List<? extends E> list,
int to) |
void |
setComparator(java.util.Comparator<? super E> comparator) |
int |
size()
Returns the number of elements in this list.
|
protected void |
sourceChanged(ListChangeListener.Change<? extends E> c)
Called when a change from the source is triggered.
|
private void |
update(ListChangeListener.Change<? extends E> c) |
private void |
updateIndices(int from,
int viewFrom,
int difference) |
private void |
updatePermutationIndexes(ListChangeListener.Change<? extends E> change) |
private void |
updateUnsorted(ListChangeListener.Change<? extends E> c) |
getSource, getSourceIndexFor, isInTransformationChain
addAll, addListener, addListener, beginChange, endChange, fireChange, hasListeners, nextAdd, nextPermutation, nextRemove, nextRemove, nextReplace, nextSet, nextUpdate, remove, removeAll, removeListener, removeListener, retainAll, setAll, setAll
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addAll, addListener, filtered, remove, removeAll, removeListener, retainAll, setAll, setAll, sorted, sorted
add, add, addAll, addAll, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, sort, spliterator, subList, toArray, toArray
addListener, removeListener
private java.util.Comparator<SortedList.Element<E>> elementComparator
private SortedList.Element<E>[] sorted
private int[] perm
private int size
private final SortHelper helper
private final SortedList.Element<E> tempElement
private ObjectProperty<java.util.Comparator<? super E>> comparator
public SortedList(ObservableList<? extends E> source, java.util.Comparator<? super E> comparator)
source
- a list to wrapcomparator
- a comparator to use or null for unordered Listpublic SortedList(ObservableList<? extends E> source)
source
- the source listSortedList(javafx.collections.ObservableList, java.util.Comparator)
protected void sourceChanged(ListChangeListener.Change<? extends E> c)
TransformationList
sourceChanged
in class TransformationList<E,E>
c
- the changepublic final ObjectProperty<java.util.Comparator<? super E>> comparatorProperty()
public final java.util.Comparator<? super E> getComparator()
public final void setComparator(java.util.Comparator<? super E> comparator)
public E get(int index)
public int size()
private void doSortWithPermutationChange()
public int getSourceIndex(int index)
TransformationList
getSourceIndex
in class TransformationList<E,E>
index
- the index in this listTransformationList.getSource()
private void updatePermutationIndexes(ListChangeListener.Change<? extends E> change)
private void updateUnsorted(ListChangeListener.Change<? extends E> c)
private void ensureSize(int size)
private void updateIndices(int from, int viewFrom, int difference)
private int findPosition(E e)
private void insertToMapping(E e, int idx)
private void setAllToMapping(java.util.List<? extends E> list, int to)
private void removeFromMapping(int idx, E e)
private void removeAllFromMapping()
private void update(ListChangeListener.Change<? extends E> c)
private void addRemove(ListChangeListener.Change<? extends E> c)