SSJ
V. 2.6.2.

umontreal.iro.lecuyer.util
Class TransformingList<OE,IE>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<OE>
          extended by umontreal.iro.lecuyer.util.TransformingList<OE,IE>
All Implemented Interfaces:
Iterable<OE>, Collection<OE>, List<OE>
Direct Known Subclasses:
ListWithStat

public abstract class TransformingList<OE,IE>
extends AbstractList<OE>

Represents a list that dynamically transforms the elements of another list. This abstract class defines a list containing an inner list of elements of a certain type, and provides facilities to convert these inner elements to outer elements of another type. A concrete subclass simply needs to provide methods for converting between the inner and the outer types.@param <IE> the inner type of the elements.


Constructor Summary
TransformingList(List<IE> fromList)
          Creates a new transforming list wrapping the inner list fromList.
 
Method Summary
 void add(int index, OE element)
           
 void clear()
           
abstract  OE convertFromInnerType(IE e)
          Converts an element in the inner list to an element of the outer type.
abstract  IE convertToInnerType(OE e)
          Converts an element of the outer type to an element for the inner list.
 OE get(int index)
           
 List<IE> getInnerList()
           
 Iterator<OE> iterator()
           
 ListIterator<OE> listIterator()
           
 ListIterator<OE> listIterator(int index)
           
 OE remove(int index)
           
 OE set(int index, OE element)
           
 int size()
           
 
Methods inherited from class java.util.AbstractList
add, addAll, equals, hashCode, indexOf, lastIndexOf, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

TransformingList

public TransformingList(List<IE> fromList)
Creates a new transforming list wrapping the inner list fromList.

Parameters:
fromList - the inner list.
Method Detail

getInnerList

public List<IE> getInnerList()

convertFromInnerType

public abstract OE convertFromInnerType(IE e)
Converts an element in the inner list to an element of the outer type.

Parameters:
e - the inner element.
Returns:
the outer element.

convertToInnerType

public abstract IE convertToInnerType(OE e)
Converts an element of the outer type to an element for the inner list.

Parameters:
e - the outer element.
Returns:
the inner element.

add

public void add(int index,
                OE element)
Specified by:
add in interface List<OE>
Overrides:
add in class AbstractList<OE>

clear

public void clear()
Specified by:
clear in interface Collection<OE>
Specified by:
clear in interface List<OE>
Overrides:
clear in class AbstractList<OE>

get

public OE get(int index)
Specified by:
get in interface List<OE>
Specified by:
get in class AbstractList<OE>

iterator

public Iterator<OE> iterator()
Specified by:
iterator in interface Iterable<OE>
Specified by:
iterator in interface Collection<OE>
Specified by:
iterator in interface List<OE>
Overrides:
iterator in class AbstractList<OE>

listIterator

public ListIterator<OE> listIterator()
Specified by:
listIterator in interface List<OE>
Overrides:
listIterator in class AbstractList<OE>

listIterator

public ListIterator<OE> listIterator(int index)
Specified by:
listIterator in interface List<OE>
Overrides:
listIterator in class AbstractList<OE>

remove

public OE remove(int index)
Specified by:
remove in interface List<OE>
Overrides:
remove in class AbstractList<OE>

set

public OE set(int index,
              OE element)
Specified by:
set in interface List<OE>
Overrides:
set in class AbstractList<OE>

size

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

SSJ
V. 2.6.2.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.