2018-12-25 21:43:17 +08:00
|
|
|
package org.springblade.core.tool.node;
|
2018-12-24 11:58:45 +08:00
|
|
|
|
|
|
|
import org.springblade.core.tool.jackson.JsonUtil;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by Blade.
|
|
|
|
*
|
2018-12-29 18:43:11 +08:00
|
|
|
* @author Chill
|
2018-12-24 11:58:45 +08:00
|
|
|
*/
|
|
|
|
public class NodeTest {
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
2018-12-27 11:35:17 +08:00
|
|
|
List<ForestNode> list = new ArrayList<>();
|
2020-04-22 18:35:13 +08:00
|
|
|
list.add(new ForestNode(1L, 0L, "1"));
|
|
|
|
list.add(new ForestNode(2L, 0L, "2"));
|
|
|
|
list.add(new ForestNode(3L, 1L, "3"));
|
|
|
|
list.add(new ForestNode(4L, 2L, "4"));
|
|
|
|
list.add(new ForestNode(5L, 3L, "5"));
|
|
|
|
list.add(new ForestNode(6L, 4L, "6"));
|
|
|
|
list.add(new ForestNode(7L, 3L, "7"));
|
|
|
|
list.add(new ForestNode(8L, 5L, "8"));
|
|
|
|
list.add(new ForestNode(9L, 6L, "9"));
|
|
|
|
list.add(new ForestNode(10L, 9L, "10"));
|
2018-12-27 11:35:17 +08:00
|
|
|
List<ForestNode> tns = ForestNodeMerger.merge(list);
|
|
|
|
tns.forEach(node ->
|
|
|
|
System.out.println(JsonUtil.toJson(node))
|
|
|
|
);
|
2018-12-24 11:58:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|