org.archive.util
Class SubList<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by org.archive.util.SubList<E>
Type Parameters:
E - the element type of the list
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>

public class SubList<E>
extends java.util.AbstractList<E>
implements java.io.Serializable

Universal sublist implementation. Instances of this class are appropriate to return from List.subList(int, int) implementations.

This implementation is efficient if the super list is random-access. LinkedList-style super lists should subclass this and provide a custom iterator.

Author:
pjack
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
SubList(java.util.List<E> delegate, int start, int end)
          Constructor.
 
Method Summary
 void add(int index, E value)
           
 E get(int index)
           
 E remove(int index)
           
 E set(int index, E value)
           
 int size()
           
 
Methods inherited from class java.util.AbstractList
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, 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

SubList

public SubList(java.util.List<E> delegate,
               int start,
               int end)
Constructor.

Parameters:
delegate - the list that create this SubList
start - the starting index of the sublist, inclusive
end - the ending index of the sublist, exclusive
Throws:
java.lang.IndexOutOfBoundsException - if start or end are outside the bounds of the list
java.lang.IllegalArgumentException - if end is less than start
Method Detail

get

public E get(int index)
Specified by:
get in interface java.util.List<E>
Specified by:
get in class java.util.AbstractList<E>

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>

set

public E set(int index,
             E value)
Specified by:
set in interface java.util.List<E>
Overrides:
set in class java.util.AbstractList<E>

add

public void add(int index,
                E value)
Specified by:
add in interface java.util.List<E>
Overrides:
add in class java.util.AbstractList<E>

remove

public E remove(int index)
Specified by:
remove in interface java.util.List<E>
Overrides:
remove in class java.util.AbstractList<E>


Copyright © 2003-2011 Internet Archive. All Rights Reserved.