umontreal.iro.lecuyer.util
Class TransformingList<OE,IE>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<OE>
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. |
TransformingList
public TransformingList(List<IE> fromList)
- Creates a new transforming list wrapping
the inner list fromList.
- Parameters:
fromList
- the inner list.
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>
To submit a bug or ask questions, send an e-mail to
Pierre L'Ecuyer.