<commit_before>package com.softartisans.timberwolf.exchange;

import java.util.Iterator;

/**
 * Base iterator class
 */
public abstract class BaseChainIterator<T> implements Iterator<T>
{
    private Iterator<T> currentIterator;

    public BaseChainIterator()
    {
        currentIterator = nextViableIterator();
    }

    /**
     * Returns the next iterator for which hasNext returns true, or null.
     * @return the next iterator for which hasNext is true, or null if no
     * such iterator exists.
     */
    private Iterator<T> nextViableIterator()
    {
        while (true)
        {
            Iterator<T> iterator = createIterator();
            if (iterator == null)
            {
                return null;
            }
            if (iterator.hasNext())
            {
                return iterator;
            }
        }
    }

    /**
     * Creates the next iterator.
     * @return the next iterator that can be created,
     * or null if there are no more iterators to be created.
     */
    protected abstract Iterator<T> createIterator();

    /**
     * Returns true if there are more elements in any of the iterators.
     * @return true if there are more items to be returned by next().
     */
    @Override
    public boolean hasNext()
    {
        if (currentIterator != null && currentIterator.hasNext())
        {
            return true;
        }
        currentIterator = nextViableIterator();
        // return false if currentIterator is null
        return currentIterator != null;
    }
<commit_msg>Don't call nextViableIterator in base constructor<commit_after>package com.softartisans.timberwolf.exchange;

import java.util.Iterator;

/**
 * Base iterator class
 */
public abstract class BaseChainIterator<T> implements Iterator<T>
{
    private Iterator<T> currentIterator;

    public BaseChainIterator()
    {
    }

    /**
     * Returns the next iterator for which hasNext returns true, or null.
     * @return the next iterator for which hasNext is true, or null if no
     * such iterator exists.
     */
    private Iterator<T> nextViableIterator()
    {
        while (true)
        {
            Iterator<T> iterator = createIterator();
            if (iterator == null)
            {
                return null;
            }
            if (iterator.hasNext())
            {
                return iterator;
            }
        }
    }

    /**
     * Creates the next iterator.
     * @return the next iterator that can be created,
     * or null if there are no more iterators to be created.
     */
    protected abstract Iterator<T> createIterator();

    /**
     * Returns true if there are more elements in any of the iterators.
     * @return true if there are more items to be returned by next().
     */
    @Override
    public boolean hasNext()
    {
        // always return false if currentIterator is null
        if (currentIterator != null && currentIterator.hasNext())
        {
            return true;
        }
        currentIterator = nextViableIterator();
        return currentIterator != null;
    }

{'fraction_non_alphanumeric': 0.08368336025848142, 'fraction_numerical': 0.0, 'mean_word_length': 1.9318181818181819, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4156001', 'n_tokens_mistral': 800, 'n_tokens_neox': 778, 'n_words': 276}