All Downloads are FREE. Search and download functionalities are using the official Maven repository.

uk.ac.rdg.resc.edal.util.LittleBigList Maven / Gradle / Ivy

The newest version!
package uk.ac.rdg.resc.edal.util;

import java.util.AbstractList;
import java.util.ArrayList;
import java.util.List;

/**
 * This is an implementation of a BigList which cannot be bigger than a normal
 * list. It is for when you need a BigList, but don't want the hassle of
 * implementing the full BigList type because you aren't going to need the capacity
 * 
 * @author Guy Griffiths
 * 
 * @param 
 */
public class LittleBigList extends ArrayList implements BigList {

    private static final long serialVersionUID = 1L;

    @Override
    public E get(long index) {
        return super.get((int) index);
    }

    @Override
    public List getAll(final List indices) {
        return new AbstractList() {
            @Override
            public E get(int index) {
                return LittleBigList.this.get(index);
            }

            @Override
            public int size() {
                return indices.size();
            }
        };
    }

    @Override
    public List getAll(long fromIndex, long toIndex) {
        return super.subList((int) fromIndex, (int) toIndex);
    }

    @Override
    public long sizeAsLong() {
        return super.size();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy