Class SortedList<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
javafx.collections.ObservableListBase<E>
javafx.collections.transformation.TransformationList<E,E>
javafx.collections.transformation.SortedList<E>
- All Implemented Interfaces:
Iterable<E>,Collection<E>,List<E>,Observable,ObservableList<E>
Wraps an ObservableList and sorts it's content.
All changes in the ObservableList are propagated immediately
to the SortedList.
Note: invalid SortedList (as a result of broken comparison) doesn't send any notification to listeners on becoming
valid again.
- Since:
- JavaFX 8.0
- See Also:
-
Property Summary
PropertiesTypePropertyDescriptionfinal ObjectProperty<Comparator<? super E>>The comparator that denotes the order of this SortedList. -
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionSortedList(ObservableList<? extends E> source) Constructs a new unordered SortedList wrapper around the source list.SortedList(ObservableList<? extends E> source, Comparator<? super E> comparator) Creates a new SortedList wrapped around the source list. -
Method Summary
Modifier and TypeMethodDescriptionfinal ObjectProperty<Comparator<? super E>>The comparator that denotes the order of this SortedList.get(int index) Returns the element at the specified position in this list.final Comparator<? super E>Gets the value of thecomparatorproperty.intgetSourceIndex(int index) Maps the index of this list's element to an index in the direct source list.intgetViewIndex(int index) Maps the index of the direct source list's element to an index in this list.final voidsetComparator(Comparator<? super E> comparator) Sets the value of thecomparatorproperty.intsize()Returns the number of elements in this list.protected voidsourceChanged(ListChangeListener.Change<? extends E> c) Called when a change from the source is triggered.Methods inherited from class javafx.collections.transformation.TransformationList
getSource, getSourceIndexFor, isInTransformationChainMethods inherited from class javafx.collections.ObservableListBase
addAll, addListener, addListener, beginChange, endChange, fireChange, hasListeners, nextAdd, nextPermutation, nextRemove, nextRemove, nextReplace, nextSet, nextUpdate, remove, removeAll, removeListener, removeListener, retainAll, setAll, setAllMethods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListMethods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, streamMethods inherited from interface java.util.List
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, toArrayMethods inherited from interface javafx.beans.Observable
addListener, removeListenerMethods inherited from interface javafx.collections.ObservableList
addAll, addListener, filtered, remove, removeAll, removeListener, retainAll, setAll, setAll, sorted
-
Property Details
-
comparator
The comparator that denotes the order of this SortedList. Null for unordered SortedList.
-
-
Constructor Details
-
SortedList
Creates a new SortedList wrapped around the source list. The source list will be sorted using the comparator provided. If null is provided, the list stays unordered and is equal to the source list.- Parameters:
source- a list to wrapcomparator- a comparator to use or null for unordered List
-
SortedList
Constructs a new unordered SortedList wrapper around the source list.- Parameters:
source- the source list- See Also:
-
-
Method Details
-
sourceChanged
Description copied from class:TransformationListCalled when a change from the source is triggered.- Specified by:
sourceChangedin classTransformationList<E,E> - Parameters:
c- the change
-
comparatorProperty
The comparator that denotes the order of this SortedList. Null for unordered SortedList.- Returns:
- the
comparatorproperty - See Also:
-
getComparator
Gets the value of thecomparatorproperty.- Property description:
- The comparator that denotes the order of this SortedList. Null for unordered SortedList.
- Returns:
- the value of the
comparatorproperty - See Also:
-
setComparator
Sets the value of thecomparatorproperty.- Property description:
- The comparator that denotes the order of this SortedList. Null for unordered SortedList.
- Parameters:
comparator- the value for thecomparatorproperty- See Also:
-
get
Returns the element at the specified position in this list.- Specified by:
getin interfaceList<E>- Specified by:
getin classAbstractList<E>- Parameters:
index- index of the element to return- Returns:
- the element at the specified position in this list
- Throws:
IndexOutOfBoundsException
-
size
public int size()Returns the number of elements in this list.- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceList<E>- Specified by:
sizein classAbstractCollection<E>- Returns:
- the number of elements in this list
-
getSourceIndex
public int getSourceIndex(int index) Description copied from class:TransformationListMaps the index of this list's element to an index in the direct source list.- Specified by:
getSourceIndexin classTransformationList<E,E> - Parameters:
index- the index in this list- Returns:
- the index of the element's origin in the source list
- See Also:
-
getViewIndex
public int getViewIndex(int index) Description copied from class:TransformationListMaps the index of the direct source list's element to an index in this list.- Specified by:
getViewIndexin classTransformationList<E,E> - Parameters:
index- the index in the source list- Returns:
- the index of the element in this list if it is contained in this list or negative value otherwise
- See Also:
-