Package com.helger.tree.sort
Class TreeWithIDSorter
- java.lang.Object
-
- com.helger.tree.sort.TreeWithIDSorter
-
@Immutable public final class TreeWithIDSorter extends Object
SortITreeWithIDinstances recursively - either by ID or by value- Author:
- Philip Helger
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <KEYTYPE extends Comparable<? super KEYTYPE>,DATATYPE,ITEMTYPE extends ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>>
voidsortByID(IBasicTree<DATATYPE,ITEMTYPE> aTree)Sort each level of the passed tree on the ID with the specified comparator.static <KEYTYPE,DATATYPE,ITEMTYPE extends ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>>
voidsortByID(IBasicTree<DATATYPE,ITEMTYPE> aTree, Comparator<? super KEYTYPE> aKeyComparator)Sort each level of the passed tree on the ID with the specified comparator.static <KEYTYPE,DATATYPE extends Comparable<? super DATATYPE>,ITEMTYPE extends ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>>
voidsortByValue(IBasicTree<DATATYPE,ITEMTYPE> aTree)Sort each level of the passed tree on the value with the specified comparator.static <KEYTYPE,DATATYPE,ITEMTYPE extends ITreeItemWithID<KEYTYPE,DATATYPE,ITEMTYPE>>
voidsortByValue(IBasicTree<DATATYPE,ITEMTYPE> aTree, Comparator<? super DATATYPE> aValueComparator)Sort each level of the passed tree on the value with the specified comparator.
-
-
-
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 typeDATATYPE- Tree item data typeITEMTYPE- 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 theComparableinterface.- Type Parameters:
KEYTYPE- Tree item key typeDATATYPE- Tree item data typeITEMTYPE- 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 typeDATATYPE- Tree item data typeITEMTYPE- 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 theComparableinterface.- Type Parameters:
KEYTYPE- Tree item key typeDATATYPE- Tree item data typeITEMTYPE- Tree item type- Parameters:
aTree- The tree to be sorted.
-
-