Package repast.simphony.util.collections
Class CompositeIndexedIterable<T>
- java.lang.Object
-
- repast.simphony.util.collections.CompositeIndexedIterable<T>
-
- All Implemented Interfaces:
Iterable<T>
,IndexedIterable<T>
public class CompositeIndexedIterable<T> extends Object implements IndexedIterable<T>
An IndexedIterable that adapts multiple IndexedItebles to behave as a single IndexedIterable.- Version:
- $Revision$ $Date$
- Author:
- Nick Collier
-
-
Constructor Summary
Constructors Constructor Description CompositeIndexedIterable()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addIndexedIterable(IndexedIterable<T> iter)
Add an indexed iterable to this CompositeIndexedIterable.void
addList(List<T> list)
Add a List to this CompositeIndexedIterable.T
get(int index)
Gets the element at the specified position in this IndexedIterable.Iterator<T>
iterator()
Returns an iterator over a set of elements of type T.int
size()
Gets the number of elements in this IndexedIterable.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
addIndexedIterable
public void addIndexedIterable(IndexedIterable<T> iter)
Add an indexed iterable to this CompositeIndexedIterable.- Parameters:
iter
-
-
addList
public void addList(List<T> list)
Add a List to this CompositeIndexedIterable.- Parameters:
list
-
-
get
public T get(int index)
Gets the element at the specified position in this IndexedIterable. Note that this method is should be used for random access to the collection. iterator() is the preferred way to iterate through this IndexedIterable.- Specified by:
get
in interfaceIndexedIterable<T>
- Parameters:
index
- the index of the element to return- Returns:
- the element at the specified position in this IndexedIterable.
- Throws:
IndexOutOfBoundsException
- if the given index is out of range (index < 0 || index >= size()).
-
size
public int size()
Gets the number of elements in this IndexedIterable.- Specified by:
size
in interfaceIndexedIterable<T>
- Returns:
- the number of elements in this IndexedIterable.
-
-