com.atlassian.confluence.api.impl.service.content.typebinding
Class TreeSorter
java.lang.Object
com.atlassian.confluence.api.impl.service.content.typebinding.TreeSorter
public class TreeSorter
- extends Object
Sorts collections that represent trees.
Method Summary |
static
|
depthFirstPreOrderSort(Collection<T> unsorted,
com.google.common.base.Function<T,List<T>> ancestorsGetter,
Comparator<T> tComparator)
Converts collections of objects with parent-child relationships into a list sorted as a flattened tree, traversed
depth-first with pre-order. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TreeSorter
public TreeSorter()
depthFirstPreOrderSort
public static <T> List<T> depthFirstPreOrderSort(Collection<T> unsorted,
com.google.common.base.Function<T,List<T>> ancestorsGetter,
Comparator<T> tComparator)
- Converts collections of objects with parent-child relationships into a list sorted as a flattened tree, traversed
depth-first with pre-order.
- Parameters:
unsorted
- an unsorted collection of objects with a parent-child relationshipancestorsGetter
- a function returning an object's ancestors with the root at the start. May return an empty list
but never null.tComparator
- compares two sibling objects in the tree
- Returns:
- a list sorted as a flattened tree, traversed depth-first with pre-order.
Copyright © 2003–2015 Atlassian. All rights reserved.