/*
 * @author Ranides Atterwim <ranides@gmail.com>
 * @copyright Ranides Atterwim
 * @license WTFPL
 * @url http://ranides.net/projects/assira
 */
package net.ranides.assira.collection.arrays;

import net.ranides.assira.collection.iterators.IntListIterator;
import net.ranides.assira.collection.iterators.RandomAccessIntIterator;
import net.ranides.assira.collection.lists.IntList;
import net.ranides.assira.collection.lists.NativeArrayList;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public final class IntArrays {
    
    private IntArrays() {
        /* utility class */
    }
    
    public static IntList asList(int... array) {
		return NativeArrayList.wrap(array);
	}
    
    public static IntListIterator iterator(int[] array) {
        return iterator(array, 0, array.length);
    }
    
    public static IntListIterator iterator(int[] array, int begin, int end) {
        return new RandomAccessIntIterator() {
            @Override
            protected int size() {
                return end-begin;
            }

            @Override
            protected int get(int index) {
                return array[begin+index];
            }

            @Override
            protected void set(int index, int value) {
                array[begin+index] = value;
            }
        };
    }
}
