176 |
* @param index the index to check |
* @param index the index to check |
177 |
* @throws IndexOutOfBoundsException if index < 0 || index > size |
* @throws IndexOutOfBoundsException if index < 0 || index > size |
178 |
*/ |
*/ |
179 |
private void rangeInclusive(int index) |
private void checkBoundsInclusive(int index) |
180 |
{ |
{ |
181 |
if (index < 0 || index > size) |
if (index < 0 || index > size) |
182 |
throw new IndexOutOfBoundsException("Index: " + index + ", Size:" |
throw new IndexOutOfBoundsException("Index: " + index + ", Size:" |
189 |
* @param index the index to check |
* @param index the index to check |
190 |
* @throws IndexOutOfBoundsException if index < 0 || index >= size |
* @throws IndexOutOfBoundsException if index < 0 || index >= size |
191 |
*/ |
*/ |
192 |
private void rangeExclusive(int index) |
private void checkBoundsExclusive(int index) |
193 |
{ |
{ |
194 |
if (index < 0 || index >= size) |
if (index < 0 || index >= size) |
195 |
throw new IndexOutOfBoundsException("Index: " + index + ", Size:" |
throw new IndexOutOfBoundsException("Index: " + index + ", Size:" |
428 |
*/ |
*/ |
429 |
public boolean addAll(int index, Collection c) |
public boolean addAll(int index, Collection c) |
430 |
{ |
{ |
431 |
rangeInclusive(index); |
checkBoundsInclusive(index); |
432 |
int csize = c.size(); |
int csize = c.size(); |
433 |
|
|
434 |
if (csize == 0) |
if (csize == 0) |
506 |
*/ |
*/ |
507 |
public Object get(int index) |
public Object get(int index) |
508 |
{ |
{ |
509 |
rangeExclusive(index); |
checkBoundsExclusive(index); |
510 |
return getEntry(index).data; |
return getEntry(index).data; |
511 |
} |
} |
512 |
|
|
520 |
*/ |
*/ |
521 |
public Object set(int index, Object o) |
public Object set(int index, Object o) |
522 |
{ |
{ |
523 |
rangeExclusive(index); |
checkBoundsExclusive(index); |
524 |
Entry e = getEntry(index); |
Entry e = getEntry(index); |
525 |
Object old = e.data; |
Object old = e.data; |
526 |
e.data = o; |
e.data = o; |
536 |
*/ |
*/ |
537 |
public void add(int index, Object o) |
public void add(int index, Object o) |
538 |
{ |
{ |
539 |
rangeInclusive(index); |
checkBoundsInclusive(index); |
540 |
Entry e = new Entry(o); |
Entry e = new Entry(o); |
541 |
|
|
542 |
if (index < size) |
if (index < size) |
565 |
*/ |
*/ |
566 |
public Object remove(int index) |
public Object remove(int index) |
567 |
{ |
{ |
568 |
rangeExclusive(index); |
checkBoundsExclusive(index); |
569 |
Entry e = getEntry(index); |
Entry e = getEntry(index); |
570 |
removeEntry(e); |
removeEntry(e); |
571 |
return e.data; |
return e.data; |
622 |
*/ |
*/ |
623 |
public ListIterator listIterator(int index) |
public ListIterator listIterator(int index) |
624 |
{ |
{ |
625 |
rangeInclusive(index); |
checkBoundsInclusive(index); |
626 |
return new LinkedListItr(index); |
return new LinkedListItr(index); |
627 |
} |
} |
628 |
|
|