gov.llnl.ontology.util
Class ExtendedList<T>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<T>
          extended by gov.llnl.ontology.util.ExtendedList<T>
All Implemented Interfaces:
Iterable<T>, Collection<T>, List<T>

public class ExtendedList<T>
extends AbstractList<T>

A List that extends an existing List without modifying the original List. New items added to this List are stored in an internal List that represents all of the values proceeding the elements in the extended List. The extended List is unmodified.

This is extermely useful for applications that need to make different extensions to an existing List but cannot make multiple copies of the original List due to memory constraints.

Author:
Keith Stevens

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ExtendedList(List<T> baseItems)
          Creates a new extended view of the given List.
 
Method Summary
 boolean add(T e)
          
 T get(int index)
          
 int size()
          
 
Methods inherited from class java.util.AbstractList
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

ExtendedList

public ExtendedList(List<T> baseItems)
Creates a new extended view of the given List. Any new items added to the ExtendedList with calls to add will be added to a secondary List, and thus leave baseItems unmodified. Only read access is given to baseItems. As long as baseItems is synchronized, it can be extended with multiple ExtendedLists without and concern.

Method Detail

add

public boolean add(T e)

Specified by:
add in interface Collection<T>
Specified by:
add in interface List<T>
Overrides:
add in class AbstractList<T>

get

public T get(int index)

Specified by:
get in interface List<T>
Specified by:
get in class AbstractList<T>

size

public int size()

Specified by:
size in interface Collection<T>
Specified by:
size in interface List<T>
Specified by:
size in class AbstractCollection<T>


Copyright © 2010-2011. All Rights Reserved.