minor fixes to adhere more closely to the java.util.List contract

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130453 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Rodney Waldhoff 2001-04-26 00:05:47 +00:00
parent 06e7d46a49
commit 1e8a31f417
1 changed files with 8 additions and 5 deletions

View File

@ -1,7 +1,7 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/CursorableLinkedList.java,v 1.1 2001/04/14 15:39:24 rwaldhoff Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/CursorableLinkedList.java,v 1.2 2001/04/26 00:05:47 rwaldhoff Exp $
* $Revision: 1.1 $ * $Revision: 1.2 $
* $Date: 2001/04/14 15:39:24 $ * $Date: 2001/04/26 00:05:47 $
* *
* ==================================================================== * ====================================================================
* *
@ -89,7 +89,7 @@ import java.lang.reflect.Array;
* <b>Note that this implementation is not synchronized.</b> * <b>Note that this implementation is not synchronized.</b>
* *
* @author Rodney Waldhoff * @author Rodney Waldhoff
* @version $Id: CursorableLinkedList.java,v 1.1 2001/04/14 15:39:24 rwaldhoff Exp $ * @version $Id: CursorableLinkedList.java,v 1.2 2001/04/26 00:05:47 rwaldhoff Exp $
* @see java.util.LinkedList * @see java.util.LinkedList
*/ */
public class CursorableLinkedList implements List, Serializable { public class CursorableLinkedList implements List, Serializable {
@ -126,6 +126,9 @@ public class CursorableLinkedList implements List, Serializable {
if(index == _size) { if(index == _size) {
add(element); add(element);
} else { } else {
if(index < 0 || index > _size) {
throw new IndexOutOfBoundsException(String.valueOf(index) + " < 0 or " + String.valueOf(index) + " > " + _size);
}
Listable succ = (isEmpty() ? null : getListableAt(index)); Listable succ = (isEmpty() ? null : getListableAt(index));
Listable pred = (null == succ ? null : succ.prev()); Listable pred = (null == succ ? null : succ.prev());
insertListable(pred,succ,element); insertListable(pred,succ,element);
@ -786,7 +789,7 @@ public class CursorableLinkedList implements List, Serializable {
*/ */
protected Listable getListableAt(int index) { protected Listable getListableAt(int index) {
if(index < 0 || index >= _size) { if(index < 0 || index >= _size) {
throw new IndexOutOfBoundsException(); throw new IndexOutOfBoundsException(String.valueOf(index) + " < 0 or " + String.valueOf(index) + " >= " + _size);
} }
if(index <=_size/2) { if(index <=_size/2) {
Listable elt = _head.next(); Listable elt = _head.next();