net.sf.molae.pipe.genimpl
Class IndexedList<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
net.sf.molae.pipe.genimpl.IndexedList<E>
- All Implemented Interfaces:
- Iterable<E>, Collection<E>, List<E>
public class IndexedList<E>
- extends AbstractList<E>
A list with an index to its entries.
This list is performant for fixed-size lists.
add and remove should not be used.
Duplicate entries are allowed.
- Since:
- 1.1
|
Constructor Summary |
IndexedList(List<E> base)
Constructs an indexed list object. |
IndexedList
public IndexedList(List<E> base)
- Constructs an indexed list object.
- Parameters:
base - the base list containing the list entries
getPositions
public Map<E,Integer> getPositions()
- Returns the positions map.
- Returns:
- the positions map.
recalculatePositions
protected void recalculatePositions()
- Recalculates the index map.
putPosition
protected void putPosition(int index,
E element)
- Checks if the specified element is a new element in the list or
at the first position and changes the position map accordingly.
- Parameters:
index - index of new elementelement - newly entered element
size
public int size()
- Specified by:
size in interface Collection<E>- Specified by:
size in interface List<E>- Specified by:
size in class AbstractCollection<E>
contains
public boolean contains(Object o)
- Specified by:
contains in interface Collection<E>- Specified by:
contains in interface List<E>- Overrides:
contains in class AbstractCollection<E>
add
public boolean add(E o)
- Specified by:
add in interface Collection<E>- Specified by:
add in interface List<E>- Overrides:
add in class AbstractList<E>
remove
public boolean remove(Object o)
- Specified by:
remove in interface Collection<E>- Specified by:
remove in interface List<E>- Overrides:
remove in class AbstractCollection<E>
clear
public void clear()
- Specified by:
clear in interface Collection<E>- Specified by:
clear in interface List<E>- Overrides:
clear in class AbstractList<E>
get
public E get(int index)
- Specified by:
get in interface List<E>- Specified by:
get in class AbstractList<E>
set
public E set(int index,
E element)
- Specified by:
set in interface List<E>- Overrides:
set in class AbstractList<E>
add
public void add(int index,
E element)
- Specified by:
add in interface List<E>- Overrides:
add in class AbstractList<E>
remove
public E remove(int index)
- Specified by:
remove in interface List<E>- Overrides:
remove in class AbstractList<E>
indexOf
public int indexOf(Object o)
- Specified by:
indexOf in interface List<E>- Overrides:
indexOf in class AbstractList<E>