edu.stanford.nlp.util
Class PaddedList<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
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
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)
|
Methods inherited from class java.util.AbstractList |
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList |
l
public final List<E> l
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)
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