org.eclipse.etrice.generator.base
Class Indexed<T>

java.lang.Object
  extended by org.eclipse.etrice.generator.base.Indexed<T>

public class Indexed<T>
extends java.lang.Object

helper class to associate indices with collection items

Author:
Henrik Rentz-Reichert

Method Summary
 int getIndex0()
           
 int getIndex1()
           
 T getValue()
           
static
<T> java.lang.Iterable<Indexed<T>>
indexed(java.lang.Iterable<T> iterable)
           
static
<T> java.lang.Iterable<Indexed<T>>
indexed(java.lang.Iterable<T> iterable, int offset)
           
 boolean isFirst()
           
 boolean isLast()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getValue

public T getValue()
Returns:
the original item of the collection

getIndex0

public int getIndex0()
Returns:
the zero based index plus the offset

getIndex1

public int getIndex1()
Returns:
the one based index plus the offset

isFirst

public boolean isFirst()
Returns:
true if this is the first element

isLast

public boolean isLast()
Returns:
true if this is the last element

indexed

public static <T> java.lang.Iterable<Indexed<T>> indexed(java.lang.Iterable<T> iterable)
Parameters:
iterable - the initial collection of items
Returns:
an indexed collection of items

indexed

public static <T> java.lang.Iterable<Indexed<T>> indexed(java.lang.Iterable<T> iterable,
                                                         int offset)
Parameters:
iterable - the initial collection of items
offset - index0 starts at offset, index1 at offset+1
Returns:
an indexed collection of items