Decorates another
List
to make it seamlessly grow when indices larger than the list size are used on add and set, avoiding most IndexOutOfBoundsExceptions.
This class avoids errors by growing when a set or add method would normally throw an IndexOutOfBoundsException. Note that IndexOutOfBoundsException IS returned for invalid negative indices.
Trying to set or add to an index larger than the size will cause the list to grow (using null
elements). Clearly, care must be taken not to use excessively large indices, as the internal list will grow to match.
Trying to use any method other than add or set with an invalid index will call the underlying list and probably result in an IndexOutOfBoundsException.
Take care when using this list with null
values, as null
is the value added when growing the list.
All sub-lists will access the underlying list directly, and will throw IndexOutOfBoundsExceptions.
This class differs from {@link LazyList} because here growth occurs onset and add, where LazyList
grows on get. However, they can be used together by decorating twice.
@see LazyList
@since Commons Collections 3.2
@version $Revision: 155406 $ $Date: 2008-04-10 13:33:15 +0100 (Thu, 10 Apr 2008) $
@author Stephen Colebourne
@author Paul Legato