net.sf.molae.pipe.trafo
Class IndexTransformedList
java.lang.Object
|
+--java.util.AbstractCollection
|
+--java.util.AbstractList
|
+--net.sf.molae.pipe.trafo.IndexTransformedList
- All Implemented Interfaces:
- Collection, List
- public class IndexTransformedList
- extends AbstractList
A list which permutes the elements of a base list.
Permutation is described by a transformer.
|
Method Summary |
void |
clear()
Removes all of the elements from this collection (optional operation). |
Object |
get(int index)
Returns the element at the specified position in this list. |
Object |
set(int index,
Object element)
Replaces the element at the specified position in this list with the
specified element (optional operation). |
int |
size()
Returns the number of elements in this list. |
| Methods inherited from class java.util.AbstractList |
add, add, addAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, subList |
IndexTransformedList
public IndexTransformedList(List base,
IntTransformer transformer)
- Constructs a IndexTransformdList object.
- Parameters:
base - the underling lists where the elements are stored.transformer - describes the index mapping
IndexTransformedList
public IndexTransformedList(List base,
int[] mapping)
- Constructs a IndexTransformdList object.
- Parameters:
base - the underling lists where the elements are stored.mapping - describes the index mapping
size
public int size()
- Returns the number of elements in this list.
- Overrides:
size in class AbstractCollection
- Returns:
- the number of elements in this list.
clear
public void clear()
- Removes all of the elements from this collection (optional operation).
- Overrides:
clear in class AbstractList
- Throws:
UnsupportedOperationException - if the clear method
is not supported by the base list
get
public Object get(int index)
- Returns the element at the specified position in this list.
This implementation returns the element at the transformed input index
from the base list.
- Overrides:
get in class AbstractList
- Parameters:
index - index of element to return.- Returns:
- the element at the specified position in this list.
- Throws:
IndexOutOfBoundsException - if the given index is out of range
(index < 0 || index >= size()).
set
public Object set(int index,
Object element)
- Replaces the element at the specified position in this list with the
specified element (optional operation).
This implementation replaces the element at the transformed input index
in the base list.
- Overrides:
set in class AbstractList
- Parameters:
index - index of element to replace.element - element to be stored at the specified position.- Returns:
- the element previously at the specified position.
- Throws:
UnsupportedOperationException - if the set method is not
supported by the base list.ClassCastException - if the class of the specified element
prevents it from being added to the base list.IllegalArgumentException - if some aspect of the specified
element prevents it from being added to the base list.IndexOutOfBoundsException - if the specified index is out of
range (index < 0 || index >= size()).