<commit_before>package edu.ucdenver.ccp.common.collections;

import java.util.Iterator;
import java.util.NoSuchElementException;

public class IteratorUtil {

	/**
	 * Returns an empty iterator
	 * 
	 * @param <T>
	 * @return
	 */
	public static <T> Iterator<T> getEmptyIterator() {
		return new Iterator<T>() {
	
			@Override
			public boolean hasNext() {
				return false;
			}
	
			@Override
			public T next() {
				if (!hasNext())
					throw new NoSuchElementException();
				return null;
			}
	
			@Override
			public void remove() {
				throw new UnsupportedOperationException("The remove operation is not supported by this iterator.");
			}
	
		};
	}

	/**
	 * Consolidates a group of Iterators into a single Iterator
	 * 
	 * @param <T>
	 * @param inputIterators
	 * @return
	 */
	public static <T> Iterator<T> consolidate(final Iterable<Iterator<T>> inputIterators) {
		final Iterator<Iterator<T>> iteratorIter = inputIterators.iterator();
		return new Iterator<T>() {
			private T nextT = null;
			private Iterator<T> currentIterator = null;
	
			@Override
			public boolean hasNext() {
				if (nextT == null) {
					if (currentIterator == null) {
						if (iteratorIter.hasNext()) {
							currentIterator = iteratorIter.next();
						} else
							return false;
					}
					if (currentIterator.hasNext()) {
						nextT = currentIterator.next();
						return true;
					}
					
					currentIterator = null;
					return hasNext();
				}
				return true;
			}
	
			@Override
			public T next() {
				if (!hasNext()) {
					throw new NoSuchElementException();
				}
	
				T thingToReturn = nextT;
				nextT = null;
				return thingToReturn;
			}
	
			@Override
			public void remove() {
				throw new UnsupportedOperationException("The remove() method is not supported for this iterator.");
			}
		};
	}
	
	public static <T> Iterator<T> consolidate(Iterator<T> iterator1, Iterator<T> iterator2) {
		return consolidate(CollectionsUtil.createList(iterator1, iterator2));
	}

}
<commit_msg>Resolving Eclipse warnings. Added JavaDoc.<commit_after>package edu.ucdenver.ccp.common.collections;

import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 * Utility class for working with Iterators
 * 
 * @author bill
 * 
 */
/**
 * @author bill
 * 
 */
public class IteratorUtil {

	/**
	 * Returns an empty iterator
	 * 
	 * @param <T>
	 * @return
	 */
	public static <T> Iterator<T> getEmptyIterator() {
		return new Iterator<T>() {

			@Override
			public boolean hasNext() {
				return false;
			}

			@Override
			public T next() {
				if (!hasNext())
					throw new NoSuchElementException();
				return null;
			}

			@Override
			public void remove() {
				throw new UnsupportedOperationException("The remove operation is not supported by this iterator.");
			}

		};
	}

	/**
	 * Consolidates a group of Iterators into a single Iterator
	 * 
	 * @param <T>
	 * @param inputIterators
	 * @return
	 */
	public static <T> Iterator<T> consolidate(final Iterable<Iterator<T>> inputIterators) {
		final Iterator<Iterator<T>> iteratorIter = inputIterators.iterator();
		return new Iterator<T>() {
			private T nextT = null;
			private Iterator<T> currentIterator = null;

			@Override
			public boolean hasNext() {
				if (nextT == null) {
					if (currentIterator == null) {
						if (iteratorIter.hasNext()) {
							currentIterator = iteratorIter.next();
						} else
							return false;
					}
					if (currentIterator.hasNext()) {
						nextT = currentIterator.next();
						return true;
					}

					currentIterator = null;
					return hasNext();
				}
				return true;
			}

			@Override
			public T next() {
				if (!hasNext()) {
					throw new NoSuchElementException();
				}

				T thingToReturn = nextT;
				nextT = null;
				return thingToReturn;
			}

			@Override
			public void remove() {
				throw new UnsupportedOperationException("The remove() method is not supported for this iterator.");
			}
		};
	}

	/**
	 * Convenience method for consolidating two Iterators
	 * 
	 * @param <T>
	 * @param iterator1
	 * @param iterator2
	 * @return
	 */
	public static <T> Iterator<T> consolidate(Iterator<T> iterator1, Iterator<T> iterator2) {
		return consolidate(CollectionsUtil.createList(iterator1, iterator2));
	}

}

{'fraction_non_alphanumeric': 0.11505882352941177, 'fraction_numerical': 0.002352941176470588, 'mean_word_length': 2.961789375582479, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3020682', 'n_tokens_mistral': 1635, 'n_tokens_neox': 1267, 'n_words': 353}