@Test public void breathFirst() throws Exception { assertEquals(Collections.<Integer>emptyList(), SortingNode.<Integer>emptyRoot().breathFirst().collect(toList())); SortingNode<Integer> tree = new SortingNode.Builder<Integer>() .childNode(100) .siblingNode(200) .childNode(210) .siblingNode(220) .parent() .siblingNode(300) .siblingNode(400) .childNode(410) .siblingNode(420) .siblingNode(430) .childNode(431) .build(); assertEquals(asList(100, 200, 300, 400, 210, 220, 410, 420, 430, 431), tree.breathFirst().collect(toList())); SortingNode<Integer> n200 = tree.getChildren().get(1); assertEquals(asList(200, 210, 220), n200.breathFirst().collect(toList())); }
public Stream<T> breathFirst() { return breathFirst(value != null); }
SortingNode { public Stream<T> breathFirst() { return breathFirst(value != null); } }
SortingNode { public Stream<T> breathFirst() { return breathFirst(value != null); } private  SortingNode(@Nullable T value,
      @Nullable SortingNode<T> parent,
      Stream<UnaryOperator<SortingNode<T>>> childrenFactory); private  SortingNode(@Nullable T value,
      @Nullable SortingNode<T> parent,
      ImmutableList<SortingNode<T>> children); }
SortingNode { public Stream<T> breathFirst() { return breathFirst(value != null); } private  SortingNode(@Nullable T value,
      @Nullable SortingNode<T> parent,
      Stream<UnaryOperator<SortingNode<T>>> childrenFactory); private  SortingNode(@Nullable T value,
      @Nullable SortingNode<T> parent,
      ImmutableList<SortingNode<T>> children); @SuppressWarnings("unchecked") static SortingNode<T> emptyRoot(); @Override String toString(); @Nullable T getValue(); @Nullable SortingNode<T> getParent(); boolean hasParent(); boolean isRoot(); List<SortingNode<T>> getChildren(); boolean hasChild(); SortingNode<T> deepSort(Comparator<SortingNode<T>> comparator); String prettyPrint(); Stream<T> depthFirst(); Stream<T> breathFirst(); }
SortingNode { public Stream<T> breathFirst() { return breathFirst(value != null); } private  SortingNode(@Nullable T value,
      @Nullable SortingNode<T> parent,
      Stream<UnaryOperator<SortingNode<T>>> childrenFactory); private  SortingNode(@Nullable T value,
      @Nullable SortingNode<T> parent,
      ImmutableList<SortingNode<T>> children); @SuppressWarnings("unchecked") static SortingNode<T> emptyRoot(); @Override String toString(); @Nullable T getValue(); @Nullable SortingNode<T> getParent(); boolean hasParent(); boolean isRoot(); List<SortingNode<T>> getChildren(); boolean hasChild(); SortingNode<T> deepSort(Comparator<SortingNode<T>> comparator); String prettyPrint(); Stream<T> depthFirst(); Stream<T> breathFirst();  }