<commit_before>package tech.tablesaw.columns.numbers;

import it.unimi.dsi.fastutil.doubles.DoubleArrayList;
import it.unimi.dsi.fastutil.doubles.DoubleIterator;
import it.unimi.dsi.fastutil.floats.FloatArrayList;
import it.unimi.dsi.fastutil.floats.FloatIterator;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntIterator;

import java.util.Iterator;

public class NumberIterator implements Iterable<Double> {

    private DoubleArrayList dList;
    private IntArrayList iList;
    private FloatArrayList fList;

    private final Object iterator;

    public NumberIterator(DoubleArrayList list) {
        this.dList = list;
        this.iterator = list.iterator();
    }

    public NumberIterator(FloatArrayList list) {
        this.fList = list;
        this.iterator = list.iterator();
    }

    public NumberIterator(IntArrayList list) {
        this.iList = list;
        this.iterator = list.iterator();
    }

    public double next() {
        if (dList != null) {
            return ((DoubleIterator) iterator).nextDouble();
        } else {
            return ((IntIterator) iterator).nextInt();
        }
    }

    public int nextInt() {
        if (dList != null) {
            return (int) ((DoubleIterator) iterator).nextDouble();
        } else {
            return ((IntIterator) iterator).nextInt();
        }
    }

    public float nextFloat() {
        if (fList != null) {
            return ((FloatIterator) iterator).nextFloat();
        }
        else if (dList != null) { // TODO (check for cast exception)
            return ((FloatIterator) iterator).nextFloat();
        } else {
            return ((IntIterator) iterator).nextInt();
        }
    }

    public boolean hasNext() {
        if (dList != null) {
            return ((DoubleIterator) iterator).hasNext();
        } else {
            return ((IntIterator) iterator).hasNext();
        }
    }

    public Iterator<Double> iterator() {
        if (dList != null) {
            return dList.iterator();
        } else {
            return new Iterator<Double>() {
                IntIterator intIterator = iList.iterator();
                @Override
                public boolean hasNext() {
                    return intIterator.hasNext();
                }

                @Override
                public Double next() {
                    return (double) intIterator.nextInt();
                }
            };
        }
    }
}<commit_msg>Fix NumberIterator (#347)<commit_after>package tech.tablesaw.columns.numbers;

import java.util.Iterator;
import java.util.ListIterator;

import it.unimi.dsi.fastutil.doubles.DoubleArrayList;
import it.unimi.dsi.fastutil.doubles.DoubleIterator;
import it.unimi.dsi.fastutil.floats.FloatArrayList;
import it.unimi.dsi.fastutil.floats.FloatIterator;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntIterator;

public class NumberIterator implements Iterable<Double> {

    private DoubleArrayList dList;
    private IntArrayList iList;
    private FloatArrayList fList;

    private final ListIterator<?> iterator;

    public NumberIterator(DoubleArrayList list) {
        this.dList = list;
        this.iterator = list.iterator();
    }

    public NumberIterator(FloatArrayList list) {
        this.fList = list;
        this.iterator = list.iterator();
    }

    public NumberIterator(IntArrayList list) {
        this.iList = list;
        this.iterator = list.iterator();
    }

    public int nextIndex() {
        return iterator.nextIndex();
    }

    public int previousIndex() {
        return iterator.previousIndex();
    }

    public double next() {
        if (dList != null) {
            return ((DoubleIterator) iterator).nextDouble();
        } else if (iList != null){
            return ((IntIterator) iterator).nextInt();
        } else {
            return ((FloatIterator) iterator).nextFloat();
        }
    }

    public int nextInt() {
        if (dList != null) {
            return (int) ((DoubleIterator) iterator).nextDouble();
        } else if (iList != null){
            return ((IntIterator) iterator).nextInt();
        } else {
            return (int) ((FloatIterator) iterator).nextFloat();
        }
    }

    public float nextFloat() {
        if (dList != null) {
            return (float) ((DoubleIterator) iterator).nextDouble();
        } else if (iList != null){
            return ((IntIterator) iterator).nextInt();
        } else {
            return ((FloatIterator) iterator).nextFloat();
        }
    }

    public boolean hasNext() {
        return iterator.hasNext();
    }

    public Iterator<Double> iterator() {
        if (dList != null) {
            return dList.iterator();
        } else if (iList != null) {
            return new Iterator<Double>() {
                IntIterator intIterator = iList.iterator();
                @Override
                public boolean hasNext() {
                    return intIterator.hasNext();
                }

                @Override
                public Double next() {
                    return (double) intIterator.nextInt();
                }
            };
        } else {
            return new Iterator<Double>() {
                FloatIterator floatIterator = fList.iterator();
                @Override
                public boolean hasNext() {
                    return floatIterator.hasNext();
                }

                @Override
                public Double next() {
                    return (double) floatIterator.nextFloat();
                }
            };
        }
    }
}
{'fraction_non_alphanumeric': 0.11016498137307078, 'fraction_numerical': 0.0005321979776476849, 'mean_word_length': 1.892765520779887, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3436821', 'n_tokens_mistral': 1502, 'n_tokens_neox': 1443, 'n_words': 336}