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:
- java.io.Serializable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>
public class PaddedList<E>
- extends java.util.AbstractList<E>
- implements java.io.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
Fields inherited from class java.util.AbstractList |
modCount |
Constructor Summary |
PaddedList(java.util.List<E> l)
With this constructor, get() will return null for
elements outside the real list. |
PaddedList(java.util.List<E> l,
E padding)
|
Method Summary |
E |
get(int i)
|
E |
getPad()
|
java.util.List<E> |
getWrappedList()
Deprecated. |
boolean |
sameInnerList(PaddedList<E> p)
Returns true if this PaddedList and another are wrapping the
same list. |
int |
size()
|
java.lang.String |
toString()
|
static
|
valueOf(java.util.List<IN> list,
IN padding)
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 |
PaddedList
public PaddedList(java.util.List<E> l)
- With this constructor, get() will return
null
for
elements outside the real list.
PaddedList
public PaddedList(java.util.List<E> l,
E padding)
getPad
public E getPad()
size
public int size()
- Specified by:
size
in interface java.util.Collection<E>
- Specified by:
size
in interface java.util.List<E>
- Specified by:
size
in class java.util.AbstractCollection<E>
get
public E get(int i)
- Specified by:
get
in interface java.util.List<E>
- Specified by:
get
in class java.util.AbstractList<E>
toString
public java.lang.String toString()
- Overrides:
toString
in class java.util.AbstractCollection<E>
getWrappedList
@Deprecated
public java.util.List<E> getWrappedList()
- Deprecated.
- This returns the inner list that was wrapped.
Use of this method should be avoided. There's currently only
one use.
- Returns:
- The inner list of the PaddedList.
valueOf
public static <IN> PaddedList<IN> valueOf(java.util.List<IN> list,
IN padding)
- A static method that provides an easy way to create a list of a
certain parametric type.
This static constructor works better with generics.
- Parameters:
list
- The list to padpadding
- The padding element (may be null)
- Returns:
- The padded list
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