net.sf.molae.pipe.number
Class IntegerList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<Integer>
          extended by net.sf.molae.pipe.number.IntegerList
All Implemented Interfaces:
Iterable<Integer>, Collection<Integer>, List<Integer>

public final class IntegerList
extends AbstractList<Integer>

A list that contains all numbers between two limits in ascending order. Member elements are not created during construction but only when needed. Therefore subsequent calls of get will not return the same objects.


Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
IntegerList(int from, int to)
          Creates a new list of integers containing all numbers including the first parameter up to the second parameter (exclusive).
 
Method Summary
 boolean contains(Object o)
           
 boolean containsAll(Collection<?> c)
           
 boolean equals(Object o)
           
 Integer get(int index)
          Returns the element at the specified position in this list.
 int indexOf(Object o)
           
 int lastIndexOf(Object o)
           
 int size()
           
 List<Integer> subList(int fromIndex, int toIndex)
          Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
 
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, hashCode, iterator, listIterator, listIterator, remove, removeRange, set
 
Methods inherited from class java.util.AbstractCollection
addAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

IntegerList

public IntegerList(int from,
                   int to)
Creates a new list of integers containing all numbers including the first parameter up to the second parameter (exclusive).

Parameters:
from - the value of the first element of the new list.
to - the value of the last element of the new list plus one.
Throws:
IllegalArgumentException - if from > to
Method Detail

size

public int size()
Specified by:
size in interface Collection<Integer>
Specified by:
size in interface List<Integer>
Specified by:
size in class AbstractCollection<Integer>

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection<Integer>
Specified by:
contains in interface List<Integer>
Overrides:
contains in class AbstractCollection<Integer>

containsAll

public boolean containsAll(Collection<?> c)
Specified by:
containsAll in interface Collection<Integer>
Specified by:
containsAll in interface List<Integer>
Overrides:
containsAll in class AbstractCollection<Integer>

equals

public boolean equals(Object o)
Specified by:
equals in interface Collection<Integer>
Specified by:
equals in interface List<Integer>
Overrides:
equals in class AbstractList<Integer>

get

public Integer get(int index)
Returns the element at the specified position in this list.

Specified by:
get in interface List<Integer>
Specified by:
get in class AbstractList<Integer>
Parameters:
index - index of element to return.
Returns:
the element at the specified position in this list.
Throws:
IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

indexOf

public int indexOf(Object o)
Specified by:
indexOf in interface List<Integer>
Overrides:
indexOf in class AbstractList<Integer>

lastIndexOf

public int lastIndexOf(Object o)
Specified by:
lastIndexOf in interface List<Integer>
Overrides:
lastIndexOf in class AbstractList<Integer>

subList

public List<Integer> subList(int fromIndex,
                             int toIndex)
Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.

Specified by:
subList in interface List<Integer>
Overrides:
subList in class AbstractList<Integer>
Parameters:
fromIndex - low endpoint (inclusive) of the subList.
toIndex - high endpoint (exclusive) of the subList.
Returns:
a view of the specified range within this list.
Throws:
IndexOutOfBoundsException - for an illegal endpoint index value (fromIndex < 0 || toIndex > size || fromIndex > toIndex).