class TypeResolvingList<T> extends AbstractList<T> {
  private final Map<T, Class<?>> elements = new CopyOnWriteLinkedHashMap<T, Class<?>>();
  private final Class<? super T> valueAccessorType;

  public TypeResolvingList(Class<? super T> valueAccessorType) {
    this.valueAccessorType = valueAccessorType;
  }

  @Override
  public void add(int index, T element) {
    addElement(element);
  }

  @Override
  public int size() {
    return elements.size();
  }

  @Override
  public boolean add(T element) {
    return addElement(element);
  }

  @Override
  public T get(int index) {
    Iterator<T> iterator = elements.keySet().iterator();
    for (int i = 0; i < index; i++) {
      iterator.next();
    }
    return iterator.next();
  }

  @Override
  public boolean addAll(Collection<? extends T> c) {<FILL_FUNCTION_BODY>}

  @Override
  public boolean addAll(int index, Collection<? extends T> c) {
    throw new UnsupportedOperationException();
  }

  @Override
  public void clear() {
    elements.clear();
  }

  @Override
  public T remove(int index) {
    T element = get(index);
    elements.remove(element);
    return element;
  }

  @Override
  public boolean remove(Object o) {
    elements.remove(o);
    return true;
  }

  @Override
  public boolean removeAll(Collection<?> c) {
    for (Object e : c) {
      @SuppressWarnings("unchecked")
      T t = (T) e;
      elements.remove(t);
    }
    return true;
  }

  @Override
  public boolean retainAll(Collection<?> c) {
    throw new UnsupportedOperationException();
  }

  @Override
  public T set(int index, T element) {
    throw new UnsupportedOperationException();
  }

  @Override
  public List<T> subList(int fromIndex, int toIndex) {
    throw new UnsupportedOperationException();
  }

  private boolean addElement(T element) {
    Assert.notNull(element, "element");
    Class<?> typeArgument = TypeResolver.resolveRawArgument(valueAccessorType, element.getClass());
    if (typeArgument == null) {
      throw new IllegalArgumentException("Must declare source type argument <T> for the " + valueAccessorType.getSimpleName());
    }
    elements.put(element, typeArgument);
    return true;
  }

  public T first(Class<?> type) {
    for (Map.Entry<T, Class<?>> entry : elements.entrySet())
      if (entry.getValue().isAssignableFrom(type))
        return entry.getKey();
    return null;
  }
}

    boolean changed = false;
    for (T e : c) {
      changed = addElement(e) || changed;
    }

    return changed;
  
<methods>public boolean add(T) ,public void add(int, T) ,public boolean addAll(int, Collection<? extends T>) ,public void clear() ,public boolean equals(java.lang.Object) ,public abstract T get(int) ,public int hashCode() ,public int indexOf(java.lang.Object) ,public Iterator<T> iterator() ,public int lastIndexOf(java.lang.Object) ,public ListIterator<T> listIterator() ,public ListIterator<T> listIterator(int) ,public T remove(int) ,public T set(int, T) ,public List<T> subList(int, int) <variables>protected transient int modCount