Skip to content

Commit

Permalink
[#17] ofTree stream close policy is documented
Browse files Browse the repository at this point in the history
  • Loading branch information
amaembo committed Aug 22, 2016
1 parent 6f44a81 commit f5bd4c3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/main/java/one/util/streamex/EntryStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -1810,6 +1810,14 @@ public static <T> EntryStream<T, T> ofPairs(T[] array) {
* used for the root node only, 1 is for root immediate children, 2 is for
* their children and so on.
*
* <p>
* The streams created by mapper may be automatically
* {@link java.util.stream.BaseStream#close() closed} after its contents
* already consumed and unnecessary anymore. It's not guaranteed that all
* created streams will be closed during the stream terminal operation. If
* it's necessary to close all the created streams, call the {@code close()}
* method of the resulting stream returned by {@code ofTree()}.
*
* @param <T> the type of tree nodes
* @param root root node of the tree
* @param mapper a non-interfering, stateless function to apply to each tree
Expand All @@ -1835,6 +1843,14 @@ public static <T> EntryStream<Integer, T> ofTree(T root, BiFunction<Integer, T,
* used for the root node only, 1 is for root immediate children, 2 is for
* their children and so on.
*
* <p>
* The streams created by mapper may be automatically
* {@link java.util.stream.BaseStream#close() closed} after its contents
* already consumed and unnecessary anymore. It's not guaranteed that all
* created streams will be closed during the stream terminal operation. If
* it's necessary to close all the created streams, call the {@code close()}
* method of the resulting stream returned by {@code ofTree()}.
*
* @param <T> the base type of tree nodes
* @param <TT> the sub-type of composite tree nodes which may have children
* @param root root node of the tree
Expand All @@ -1852,5 +1868,4 @@ public static <T, TT extends T> EntryStream<Integer, T> ofTree(T root, Class<TT>
BiFunction<Integer, TT, Stream<T>> mapper) {
return ofTree(root, (d, t) -> collectionClass.isInstance(t) ? mapper.apply(d, (TT) t) : null);
}

}
16 changes: 16 additions & 0 deletions src/main/java/one/util/streamex/StreamEx.java
Original file line number Diff line number Diff line change
Expand Up @@ -2598,6 +2598,14 @@ public static <U, V, T> StreamEx<T> zip(U[] first, V[] second, BiFunction<? supe
* Return a new {@link StreamEx} containing all the nodes of tree-like data
* structure in depth-first order.
*
* <p>
* The streams created by mapper may be automatically
* {@link java.util.stream.BaseStream#close() closed} after its contents
* already consumed and unnecessary anymore. It's not guaranteed that all
* created streams will be closed during the stream terminal operation. If
* it's necessary to close all the created streams, call the {@code close()}
* method of the resulting stream returned by {@code ofTree()}.
*
* @param <T> the type of tree nodes
* @param root root node of the tree
* @param mapper a non-interfering, stateless function to apply to each tree
Expand All @@ -2617,6 +2625,14 @@ public static <T> StreamEx<T> ofTree(T root, Function<T, Stream<T>> mapper) {
* Return a new {@link StreamEx} containing all the nodes of tree-like data
* structure in depth-first order.
*
* <p>
* The streams created by mapper may be automatically
* {@link java.util.stream.BaseStream#close() closed} after its contents
* already consumed and unnecessary anymore. It's not guaranteed that all
* created streams will be closed during the stream terminal operation. If
* it's necessary to close all the created streams, call the {@code close()}
* method of the resulting stream returned by {@code ofTree()}.
*
* @param <T> the base type of tree nodes
* @param <TT> the sub-type of composite tree nodes which may have children
* @param root root node of the tree
Expand Down

0 comments on commit f5bd4c3

Please sign in to comment.