reschke commented on code in PR #2267: URL: https://github.com/apache/jackrabbit-oak/pull/2267#discussion_r2075125407
########## oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/IteratorUtils.java: ########## @@ -474,5 +479,57 @@ public static <E> Iterator<E> cycle(final E... elements) { public static <E> Iterator<E> cycle(final Iterable<E> iterable) { return org.apache.commons.collections4.IteratorUtils.loopingIterator(CollectionUtils.toCollection(iterable)); } + + /** + * Returns an iterator that partitions the elements of another iterator into fixed-size lists. + * <p> + * This method creates a new iterator that will group elements from the source iterator + * into lists of the specified size. The final list may be smaller than the requested size + * if there are not enough elements remaining in the source iterator. + * <p> + * The returned lists are unmodifiable. The source iterator is consumed only as the + * returned iterator is advanced. + * <p> + * Example usage: + * <pre> + * Iterator<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5).iterator(); + * Iterator<List<Integer>> partitioned = IteratorUtils.partition(numbers, 2); + * // partitioned will iterate through [1, 2], [3, 4], [5] + * </pre> + * + * @param <T> the type of elements in the source iterator + * @param iterator the source iterator to partition, must not be null + * @param size the size of each partition, must be greater than 0 + * @return an iterator of fixed-size lists containing the elements of the source iterator + * @throws NullPointerException if the iterator is null + * @throws IllegalArgumentException if size is less than or equal to 0 Review Comment: less than? -- 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: oak-dev-unsubscr...@jackrabbit.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org