1 |
|
/* |
2 |
< |
* @(#)AbstractList.java 1.50 05/12/06 |
2 |
> |
* %W% %E% |
3 |
|
* |
4 |
|
* Copyright 2006 Sun Microsystems, Inc. All rights reserved. |
5 |
|
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. |
39 |
|
* collection being implemented admits a more efficient implementation.<p> |
40 |
|
* |
41 |
|
* This class is a member of the |
42 |
< |
* <a href="{@docRoot}/../guide/collections/index.html"> |
42 |
> |
* <a href="{@docRoot}/../technotes/guides/collections/index.html"> |
43 |
|
* Java Collections Framework</a>. |
44 |
|
* |
45 |
|
* @author Josh Bloch |
617 |
|
int length; // Number of elements in this sublist |
618 |
|
|
619 |
|
SubList(AbstractList<E> base, |
620 |
< |
AbstractList<E> parent, |
621 |
< |
int baseIndex, |
622 |
< |
int fromIndex, |
620 |
> |
AbstractList<E> parent, |
621 |
> |
int baseIndex, |
622 |
> |
int fromIndex, |
623 |
|
int toIndex) { |
624 |
|
if (fromIndex < 0) |
625 |
|
throw new IndexOutOfBoundsException("fromIndex = " + fromIndex); |
640 |
|
* Returns an IndexOutOfBoundsException with nicer message |
641 |
|
*/ |
642 |
|
private IndexOutOfBoundsException indexError(int index) { |
643 |
< |
return new IndexOutOfBoundsException("Index: " + index + |
643 |
> |
return new IndexOutOfBoundsException("Index: " + index + |
644 |
|
", Size: " + length); |
645 |
|
} |
646 |
|
|
715 |
|
} |
716 |
|
|
717 |
|
public List<E> subList(int fromIndex, int toIndex) { |
718 |
< |
return new SubList(base, this, fromIndex + baseOffset, |
718 |
> |
return new SubList(base, this, fromIndex + baseOffset, |
719 |
|
fromIndex, toIndex); |
720 |
|
} |
721 |
|
|
750 |
|
int cursor; // Current index |
751 |
|
int fence; // Upper bound on cursor |
752 |
|
int lastRet; // Index of returned element, or -1 |
753 |
< |
int expectedModCount; // Expected modCount of base |
753 |
> |
int expectedModCount; // Expected modCount of base |
754 |
|
|
755 |
|
SubListIterator(SubList<E> list, int index) { |
756 |
|
this.lastRet = -1; |
861 |
|
|
862 |
|
class RandomAccessSubList<E> extends SubList<E> implements RandomAccess { |
863 |
|
RandomAccessSubList(AbstractList<E> base, |
864 |
< |
AbstractList<E> parent, int baseIndex, |
864 |
> |
AbstractList<E> parent, int baseIndex, |
865 |
|
int fromIndex, int toIndex) { |
866 |
|
super(base, parent, baseIndex, fromIndex, toIndex); |
867 |
|
} |