ch.elca.el4j.util.collections.impl
Class ExtendedArrayList<T>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<T>
              extended by ch.elca.el4j.util.collections.impl.ExtendedArrayList<T>
Type Parameters:
T - the member type
All Implemented Interfaces:
ExtendedList<T>, ExtendedReorderableList<T>, ExtendedWritableList<T>, Serializable, Cloneable, Iterable<T>, Collection<T>, List<T>, RandomAccess

public class ExtendedArrayList<T>
extends ArrayList<T>
implements ExtendedWritableList<T>

A default implementation of the ExtendedWritableList interface.

Author:
Adrian Moos (AMS)
See Also:
Serialized Form
File-location:
ExtendedArrayList
Last check-in date:
2009-08-04 14:35:53 +0200 (Di, 04. Aug 2009) by swismer for revision 3875

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ExtendedArrayList()
          creates an empty list.
ExtendedArrayList(Iterable<T> iter)
          Creates a list by shallow-copying iter.
ExtendedArrayList(T... ts)
          creates a list containing the arguments.
 
Method Summary
 void add(T... ts)
          equivalent to calling add for each argument, in order.
 FilteredList<T> filtered(Filter<? super T> filter)
          Convenience method returning a filtered view on this collection.
<O> TransformedList<T,O>
mapped(Function<? super T,O> function)
          Convenience method returning a TransformedList view to this list.
 void orderLike(List<? extends T> example)
          Reorders this list's elements by example.
 void remove(T... ts)
          equivalent to calling remove for each argument, in order.
 void swap(int i, int j)
          exchanges the elements located at indices i and j.
 T[] toArray(Class<T> c)
          
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
 

Constructor Detail

ExtendedArrayList

public ExtendedArrayList()
creates an empty list.


ExtendedArrayList

public ExtendedArrayList(T... ts)
creates a list containing the arguments.

Parameters:
ts - .

ExtendedArrayList

public ExtendedArrayList(Iterable<T> iter)
Creates a list by shallow-copying iter.

Parameters:
iter - the iterable to copy.
Method Detail

add

public void add(T... ts)
equivalent to calling add for each argument, in order.

Specified by:
add in interface ExtendedWritableList<T>
Parameters:
ts - the objects to be added

remove

public void remove(T... ts)
equivalent to calling remove for each argument, in order.

Specified by:
remove in interface ExtendedWritableList<T>
Parameters:
ts - the objects to be added

swap

public void swap(int i,
                 int j)
exchanges the elements located at indices i and j.

Specified by:
swap in interface ExtendedReorderableList<T>
Parameters:
i - ...
j - ...

orderLike

public void orderLike(List<? extends T> example)
               throws NoSuchElementException
Reorders this list's elements by example. This method makes sure that the result will start with the sublist example as far as element equality is concerned, or throws a NoSuchElementException if this is not possible. In either case, the order of the remaining elements may be affected. This method may require quadratic time.

Formally, if this method completes normally, the condition ∀ i < example.size(); c.apply(this.get(i)).equals(example.get(i)) is true.

Specified by:
orderLike in interface ExtendedReorderableList<T>
Parameters:
example - a list whose elements are in the descired order
Throws:
NoSuchElementException - if the example's order can not be duplicated by reordering alone.

toArray

public T[] toArray(Class<T> c)

Specified by:
toArray in interface ExtendedList<T>
Parameters:
c - the element type for the new array
Returns:
an new array containing this list's contents

mapped

public <O> TransformedList<T,O> mapped(Function<? super T,O> function)
Convenience method returning a TransformedList view to this list.

Specified by:
mapped in interface ExtendedList<T>
Parameters:
function - the transformation function to apply to each element
Returns:
see above

filtered

public FilteredList<T> filtered(Filter<? super T> filter)
Convenience method returning a filtered view on this collection.

Specified by:
filtered in interface ExtendedList<T>
Parameters:
filter - the filter deciding which elements are included


Copyright © 2005-2011 ELCA. All Rights Reserved.