Ordered list Java

  • All Implemented Interfaces:Iterable, Collection, List, Observable, ObservableList
    public final class SortedList extends TransformationList

    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.0See Also:TransformationList
    • Constructor Detail

      • publicSortedList​(ObservableListE>source, ComparatorE>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 - a list to wrapcomparator - a comparator to use or null for unordered List
    • Method Detail

      • getComparator

        public finalComparatorE>getComparator​()

        Gets the value of the property comparator.

        Property description:The comparator that denotes the order of this SortedList. Null for unordered SortedList.
      • setComparator

        public finalvoidsetComparator​(ComparatorE>comparator)

        Sets the value of the property comparator.

        Property description:The comparator that denotes the order of this SortedList. Null for unordered SortedList.
      • get

        publicEget​(intindex)

        Returns the element at the specified position in this list.

        Specified by:getin interfaceListSpecified by:getin classAbstractListParameters:index - index of the element to returnReturns:the element at the specified position in this listThrows:IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())
      • getSourceIndex

        publicintgetSourceIndex​(intindex)

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

        Specified by:getSourceIndexin classTransformationListParameters:index - the index in this listReturns:the index of the element's origin in the source listSee Also:TransformationList.getSource()