ibessonov commented on a change in pull request #402:
URL: https://github.com/apache/ignite-3/pull/402#discussion_r731788730
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/util/CollectionUtils.java
##########
@@ -193,6 +198,45 @@ else if (mapper == null)
}
}
+ /**
+ * Converts iterator to stream.
+ *
+ * @param iterator Iterator.
+ * @param <T> Type of elements in iterator.
+ * @return Stream.
+ */
+ public static <T> Stream<T> iteratorToStream(Iterator<T> iterator) {
+ return stream(spliteratorUnknownSize(iterator, Spliterator.ORDERED),
false);
+ }
+
+ /**
+ * Returns iterator that iterates list in reverse order.
+ *
+ * @param list List.
+ * @param <T> Type of elements in list.
+ * @return Reverse iterator.
+ */
+ public static <T> Iterator<T> reverseIterator(List<? extends T> list) {
+ return new Iterator<T>() {
+ private final ListIterator<? extends T> iter =
list.listIterator(list.size());
+
+ /** {@inheritDoc} */
+ @Override public boolean hasNext() {
+ return iter.hasPrevious();
+ }
+
+ /** {@inheritDoc} */
+ @Override public T next() {
+ return iter.previous();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void remove() {
+ iter.remove();
Review comment:
As far as I know, methods contract doesn't specify what to do in this
case
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]