1 |
/* AbstractList.java -- Abstract implementation of most of List |
/* AbstractList.java -- Abstract implementation of most of List |
2 |
Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. |
Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
613 |
|
|
614 |
/** |
/** |
615 |
* This class follows the implementation requirements set forth in |
* This class follows the implementation requirements set forth in |
616 |
* {@link AbstractList#subList(int, int)}. Some compilers have problems |
* {@link AbstractList#subList(int, int)}. It matches Sun's implementation |
617 |
* with AbstractList.this.modCount if this class is nested in AbstractList, |
* by using a non-public top-level class in the same package. |
|
* even though the JLS defines that to be legal, so we make it a top-level |
|
|
* class. |
|
618 |
* |
* |
619 |
* @author Original author unknown |
* @author Original author unknown |
620 |
* @author Eric Blake <ebb9@email.byu.edu> |
* @author Eric Blake <ebb9@email.byu.edu> |
621 |
*/ |
*/ |
622 |
class SubList extends AbstractList |
class SubList extends AbstractList |
623 |
{ |
{ |
624 |
private final AbstractList backingList; |
// Package visible, for use by iterator. |
625 |
private final int offset; |
/** The original list. */ |
626 |
private int size; |
final AbstractList backingList; |
627 |
|
/** The index of the first element of the sublist. */ |
628 |
|
final int offset; |
629 |
|
/** The size of the sublist. */ |
630 |
|
int size; |
631 |
|
|
632 |
/** |
/** |
633 |
* Construct the sublist. |
* Construct the sublist. |
651 |
* @throws ConcurrentModificationException if the backing list has been |
* @throws ConcurrentModificationException if the backing list has been |
652 |
* modified externally to this sublist |
* modified externally to this sublist |
653 |
*/ |
*/ |
654 |
// This will get inlined, since it is private. |
// This can be inlined. Package visible, for use by iterator. |
655 |
private void checkMod() |
void checkMod() |
656 |
{ |
{ |
657 |
if (modCount != backingList.modCount) |
if (modCount != backingList.modCount) |
658 |
throw new ConcurrentModificationException(); |
throw new ConcurrentModificationException(); |