edu.stanford.nlp.util
Class PaddedList<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by edu.stanford.nlp.util.PaddedList<E>
All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, List<E>

public class PaddedList<E>
extends AbstractList<E>
implements Serializable

A PaddedList wraps another list, presenting an apparently infinite list by padding outside the real confines of the list with a default value. Note that size() returns the true size, but get() works for any number.

Author:
Christopher Manning
See Also:
Serialized Form

Field Summary
 List<E> l
           
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
PaddedList(List<E> l)
          With this constructor, get() will return null for elements outside the real list.
PaddedList(List<E> l, E padding)
           
 
Method Summary
 E get(int i)
           
 E getPad()
           
 boolean sameInnerList(PaddedList<E> p)
          Returns true if this PaddedList and another are wrapping the same list.
 int size()
           
 String toString()
           
static
<F> PaddedList<F>
valueOf(List<F> list)
          A static method that provides an easy way to create a list of a certain parametric type.
 
Methods inherited from class java.util.AbstractList
add, 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
 
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
 

Field Detail

l

public final List<E> l
Constructor Detail

PaddedList

public PaddedList(List<E> l)
With this constructor, get() will return null for elements outside the real list.


PaddedList

public PaddedList(List<E> l,
                  E padding)
Method Detail

getPad

public E getPad()

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>

get

public E get(int i)
Specified by:
get in interface List<E>
Specified by:
get in class AbstractList<E>

toString

public String toString()
Overrides:
toString in class AbstractCollection<E>

valueOf

public static <F> PaddedList<F> valueOf(List<F> list)
A static method that provides an easy way to create a list of a certain parametric type.


sameInnerList

public boolean sameInnerList(PaddedList<E> p)
Returns true if this PaddedList and another are wrapping the same list. This is tested as ==. Kinda yucky, but sometimes you want to know.



Stanford NLP Group