Class TreeWithIDSorter


  • @Immutable
    public final class TreeWithIDSorter
    extends Object
    Sort ITreeWithID instances recursively - either by ID or by value
    Author:
    Philip Helger
    • Method Detail

      • sortByID

        public static <KEYTYPE,​DATATYPE,​ITEMTYPE extends ITreeItemWithID<KEYTYPE,​DATATYPE,​ITEMTYPE>> void sortByID​(@Nonnull
                                                                                                                                           IBasicTree<DATATYPE,​ITEMTYPE> aTree,
                                                                                                                                           @Nonnull
                                                                                                                                           Comparator<? super KEYTYPE> aKeyComparator)
        Sort each level of the passed tree on the ID with the specified comparator.
        Type Parameters:
        KEYTYPE - Tree item key type
        DATATYPE - Tree item data type
        ITEMTYPE - Tree item type
        Parameters:
        aTree - The tree to be sorted.
        aKeyComparator - The comparator to be used for sorting the tree item keys on each level.
      • sortByID

        public static <KEYTYPE extends Comparable<? super KEYTYPE>,​DATATYPE,​ITEMTYPE extends ITreeItemWithID<KEYTYPE,​DATATYPE,​ITEMTYPE>> void sortByID​(@Nonnull
                                                                                                                                                                               IBasicTree<DATATYPE,​ITEMTYPE> aTree)
        Sort each level of the passed tree on the ID with the specified comparator. This method assumes that the IDs in the tree item implement the Comparable interface.
        Type Parameters:
        KEYTYPE - Tree item key type
        DATATYPE - Tree item data type
        ITEMTYPE - Tree item type
        Parameters:
        aTree - The tree to be sorted.
      • sortByValue

        public static <KEYTYPE,​DATATYPE,​ITEMTYPE extends ITreeItemWithID<KEYTYPE,​DATATYPE,​ITEMTYPE>> void sortByValue​(@Nonnull
                                                                                                                                              IBasicTree<DATATYPE,​ITEMTYPE> aTree,
                                                                                                                                              @Nonnull
                                                                                                                                              Comparator<? super DATATYPE> aValueComparator)
        Sort each level of the passed tree on the value with the specified comparator.
        Type Parameters:
        KEYTYPE - Tree item key type
        DATATYPE - Tree item data type
        ITEMTYPE - Tree item type
        Parameters:
        aTree - The tree to be sorted.
        aValueComparator - The comparator to be used for sorting the tree item keys on each level.
      • sortByValue

        public static <KEYTYPE,​DATATYPE extends Comparable<? super DATATYPE>,​ITEMTYPE extends ITreeItemWithID<KEYTYPE,​DATATYPE,​ITEMTYPE>> void sortByValue​(@Nonnull
                                                                                                                                                                                   IBasicTree<DATATYPE,​ITEMTYPE> aTree)
        Sort each level of the passed tree on the value with the specified comparator. This method assumes that the values in the tree item implement the Comparable interface.
        Type Parameters:
        KEYTYPE - Tree item key type
        DATATYPE - Tree item data type
        ITEMTYPE - Tree item type
        Parameters:
        aTree - The tree to be sorted.