Top Description Inners Fields Constructors Methods
javafx.collections.transformation

public final Class SortedList<E>

extends TransformationList<E, E>
Class Inheritance
Type Parameters
<E>
the list element type
Imports
com.sun.javafx.collections.NonIterableChange.SimplePermutationChange, .SortHelper, .SourceAdapterChange, java.util.ArrayList, .Arrays, .Comparator, .List, .Objects, javafx.beans.NamedArg, javafx.beans.property.ObjectProperty, .ObjectPropertyBase, javafx.collections.ListChangeListener.Change, .ObservableList

Wraps an ObservableList and sorts its 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
TransformationList

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private ObjectProperty<Comparator<? super E>>
comparator

The comparator that denotes the order of this SortedList.

private Comparator<SortedList.Element<E>>
private final SortHelper
private int[]
private int
private SortedList.Element<E>[]
private final SortedList.Element<E>

Constructor Summary

AccessConstructor and Description
public
SortedList(ObservableList<? extends E>
a list to wrap
source
,
Comparator<? super E>
a comparator to use or null for unordered List
comparator
)

Creates a new SortedList wrapped around the source list.

public
SortedList(ObservableList<? extends E>
the source list
source
)

Constructs a new unordered SortedList wrapper around the source list.

Method Summary

Modifier and TypeMethod and Description
private void
public final ObjectProperty<Comparator<? super E>>
private void
private void
ensureSize(int size)

private int
public E

Returns:

the element at the specified position in this list
get
(int
index of the element to return
index
)

Implements abstract java.util.AbstractList.get.

Implements java.util.List.get.

Returns the element at the specified position in this list.

public final Comparator<? super E>
public int
getSourceIndex(int index)

Implements abstract javafx.collections.transformation.TransformationList.getSourceIndex.

Maps the index of this list's element to an index in the direct source list.

public int
getViewIndex(int index)

Implements abstract javafx.collections.transformation.TransformationList.getViewIndex.

Maps the index of the direct source list's element to an index in this list.

private void
insertToMapping(E e, int idx)

private void
private void
removeFromMapping(int idx, E e)

private void
setAllToMapping(List<? extends E> list, int to)

public final void
setComparator(Comparator<? super E> comparator)

public int

Returns:

the number of elements in this list
size
()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.List.size, java.util.Collection.size.

Returns the number of elements in this list.

protected void
sourceChanged(ListChangeListener.Change<? extends E> c)

Implements abstract javafx.collections.transformation.TransformationList.sourceChanged.

Called when a change from the source is triggered.

private void
private void
updateIndices(int from, int viewFrom, int difference)

private void
private void
Inherited from javafx.collections.transformation.TransformationList:
getSourcegetSourceIndexForisInTransformationChain

Field Detail

comparatorback to summary
private ObjectProperty<Comparator<? super E>> comparator

The comparator that denotes the order of this SortedList. Null for unordered SortedList.

elementComparatorback to summary
private Comparator<SortedList.Element<E>> elementComparator
helperback to summary
private final SortHelper helper
permback to summary
private int[] perm
sizeback to summary
private int size
sortedback to summary
private SortedList.Element<E>[] sorted
tempElementback to summary
private final SortedList.Element<E> tempElement

Constructor Detail

SortedListback to summary
public SortedList(ObservableList<? extends E> source, Comparator<? super E> comparator)

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:ObservableList<? extends E>

a list to wrap

comparator:Comparator<? super E>

a comparator to use or null for unordered List

Annotations
@SuppressWarnings:unchecked
SortedListback to summary
public SortedList(ObservableList<? extends E> source)

Constructs a new unordered SortedList wrapper around the source list.

Parameters
source:ObservableList<? extends E>

the source list

See Also
SortedList(javafx.collections.ObservableList, java.util.Comparator)

Method Detail

addRemoveback to summary
private void addRemove(ListChangeListener.Change<? extends E> c)
comparatorPropertyback to summary
public final ObjectProperty<Comparator<? super E>> comparatorProperty()
doSortWithPermutationChangeback to summary
private void doSortWithPermutationChange()
ensureSizeback to summary
private void ensureSize(int size)
findPositionback to summary
private int findPosition(E e)
getback to summary
public E get(int index)

Implements abstract java.util.AbstractList.get.

Implements java.util.List.get.

Returns the element at the specified position in this list.

Parameters
index:int

index of the element to return

Returns:E

the element at the specified position in this list

Annotations
@Override
getComparatorback to summary
public final Comparator<? super E> getComparator()
getSourceIndexback to summary
public int getSourceIndex(int index)

Implements abstract javafx.collections.transformation.TransformationList.getSourceIndex.

Doc from javafx.collections.transformation.TransformationList.getSourceIndex.

Maps the index of this list's element to an index in the direct source list.

Annotations
@Override
getViewIndexback to summary
public int getViewIndex(int index)

Implements abstract javafx.collections.transformation.TransformationList.getViewIndex.

Doc from javafx.collections.transformation.TransformationList.getViewIndex.

Maps the index of the direct source list's element to an index in this list.

Annotations
@Override
insertToMappingback to summary
private void insertToMapping(E e, int idx)
removeAllFromMappingback to summary
private void removeAllFromMapping()
removeFromMappingback to summary
private void removeFromMapping(int idx, E e)
setAllToMappingback to summary
private void setAllToMapping(List<? extends E> list, int to)
setComparatorback to summary
public final void setComparator(Comparator<? super E> comparator)
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.List.size, java.util.Collection.size.

Returns the number of elements in this list.

Returns:int

the number of elements in this list

Annotations
@Override
sourceChangedback to summary
protected void sourceChanged(ListChangeListener.Change<? extends E> c)

Implements abstract javafx.collections.transformation.TransformationList.sourceChanged.

Doc from javafx.collections.transformation.TransformationList.sourceChanged.

Called when a change from the source is triggered.

Annotations
@Override
updateback to summary
private void update(ListChangeListener.Change<? extends E> c)
updateIndicesback to summary
private void updateIndices(int from, int viewFrom, int difference)
updatePermutationIndexesback to summary
private void updatePermutationIndexes(ListChangeListener.Change<? extends E> change)
updateUnsortedback to summary
private void updateUnsorted(ListChangeListener.Change<? extends E> c)
javafx.collections.transformation back to summary

private Class SortedList.Element<E>

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private E
e

private int

Constructor Summary

AccessConstructor and Description
public
Element(E e, int index)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

eback to summary
private E e
indexback to summary
private int index

Constructor Detail

Elementback to summary
public Element(E e, int index)
javafx.collections.transformation back to summary

private Class SortedList.ElementComparator<E>

extends Object
implements Comparator<SortedList.Element<E>>
Class Inheritance
  • java.lang.Object
  • javafx.collections.transformation.SortedList.ElementComparator
All Implemented Interfaces
java.util.Comparator

Field Summary

Modifier and TypeField and Description
private final Comparator<? super E>

Constructor Summary

AccessConstructor and Description
public
ElementComparator(Comparator<? super E> comparator)

Method Summary

Modifier and TypeMethod and Description
public int
compare(SortedList.Element<E> o1, SortedList.Element<E> o2)

Implements java.util.Comparator.compare.

Compares its two arguments for order.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

comparatorback to summary
private final Comparator<? super E> comparator

Constructor Detail

ElementComparatorback to summary
public ElementComparator(Comparator<? super E> comparator)

Method Detail

compareback to summary
public int compare(SortedList.Element<E> o1, SortedList.Element<E> o2)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Annotations
@Override