Back to index

plt-scheme  4.2.1
Public Member Functions | Package Functions | Package Attributes | Private Member Functions | Private Attributes
java.util.AbstractList.lIListIterator Class Reference

Obtain a ListIterator over this list, starting at a given position. More...

Inheritance diagram for java.util.AbstractList.lIListIterator:
Inheritance graph
[legend]
Collaboration diagram for java.util.AbstractList.lIListIterator:
Collaboration graph
[legend]

List of all members.

Public Member Functions

boolean hasNext ()
 Tests whether there are elements remaining in the list in the forward direction.
boolean hasPrevious ()
 Tests whether there are elements remaining in the list in the reverse direction.
Object next ()
 Obtain the next element in the list in the forward direction.
Object previous ()
 Obtain the next element in the list in the reverse direction.
int nextIndex ()
 Find the index of the element that would be returned by a call to next.
int previousIndex ()
 Find the index of the element that would be returned by a call to previous.
void remove ()
 Remove from the list the element last returned by a call to next or previous (optional operation).
void set (Object o)
 Replace the element last returned by a call to next or previous with a given object (optional operation).
void add (Object o)
 Insert an element into the list at the current position of the iterator (optional operation).

Package Functions

 lIListIterator (int i)

Package Attributes

int index

Private Member Functions

void checkModL ()

Private Attributes

int knownMod = AbstractList.this.modCount
int position = index
int lastReturned = -1
int size = AbstractList.this.size()

Detailed Description

Obtain a ListIterator over this list, starting at a given position.

A first call to next() would return the same as get(index), and a first call to previous() would return the same as get(index - 1).

This implementation uses size(), get(int), set(int, Object), add(int, Object), and remove(int) of the backing list, and does not support remove, set, or add unless the list does. This implementation is fail-fast if you correctly maintain modCount.

Parameters:
indexthe position, between 0 and size() inclusive, to begin the iteration from
Returns:
a ListIterator over the elements of this list, in order, starting at index
Exceptions:
IndexOutOfBoundsExceptionif index < 0 || index > size()
See also:
modCount

Definition at line 411 of file AbstractList.java.


Constructor & Destructor Documentation

Definition at line 415 of file AbstractList.java.

{ index = i; }

Member Function Documentation

Insert an element into the list at the current position of the iterator (optional operation).

The element is inserted in between the element that would be returned by previous and the element that would be returned by next. After the insertion, a subsequent call to next is unaffected, but a call to previous returns the item that was added. The values returned by nextIndex() and previousIndex() are incremented.

Parameters:
othe object to insert into the list
Exceptions:
ClassCastExceptionthe object is of a type which cannot be added to this list
IllegalArgumentExceptionsome other aspect of the object stops it being added to this list
UnsupportedOperationExceptionif this ListIterator does not support the add operation

Implements java.util.ListIterator.

Definition at line 491 of file AbstractList.java.

      {
        checkModL();
        AbstractList.this.add(position++, o);
        size++;
        lastReturned = -1;
        knownMod = AbstractList.this.modCount;
      }

Here is the call graph for this function:

Definition at line 423 of file AbstractList.java.

      {
        if (knownMod != AbstractList.this.modCount)
          throw new ConcurrentModificationException();
      }

Here is the caller graph for this function:

Tests whether there are elements remaining in the list in the forward direction.

In other words, next() will not fail with a NoSuchElementException.

Returns:
true if the list continues in the forward direction

Implements java.util.ListIterator.

Definition at line 429 of file AbstractList.java.

      {
        checkModL();
        return position < size;
      }

Here is the call graph for this function:

Tests whether there are elements remaining in the list in the reverse direction.

In other words, previous() will not fail with a NoSuchElementException.

Returns:
true if the list continues in the reverse direction

Implements java.util.ListIterator.

Definition at line 435 of file AbstractList.java.

      {
        checkModL();
        return position > 0;
      }

Here is the call graph for this function:

Obtain the next element in the list in the forward direction.

Repeated calls to next may be used to iterate over the entire list, or calls to next and previous may be used together to go forwards and backwards. Alternating calls to next and previous will return the same element.

Returns:
the next element in the list in the forward direction
Exceptions:
NoSuchElementExceptionif there are no more elements

Implements java.util.ListIterator.

Definition at line 441 of file AbstractList.java.

      {
        checkModL();
        if (position == size)
          throw new NoSuchElementException();
        lastReturned = position;
        return AbstractList.this.get(position++);
      }

Here is the call graph for this function:

Find the index of the element that would be returned by a call to next.

If hasNext() returns false, this returns the list size.

Returns:
the index of the element that would be returned by next()

Implements java.util.ListIterator.

Definition at line 459 of file AbstractList.java.

      {
        checkModL();
        return position;
      }

Here is the call graph for this function:

Obtain the next element in the list in the reverse direction.

Repeated calls to previous may be used to iterate backwards over the entire list, or calls to next and previous may be used together to go forwards and backwards. Alternating calls to next and previous will return the same element.

Returns:
the next element in the list in the reverse direction
Exceptions:
NoSuchElementExceptionif there are no more elements

Implements java.util.ListIterator.

Definition at line 450 of file AbstractList.java.

      {
        checkModL();
        if (position == 0)
          throw new NoSuchElementException();
        lastReturned = --position;
        return AbstractList.this.get(lastReturned);
      }

Here is the call graph for this function:

Find the index of the element that would be returned by a call to previous.

If hasPrevious() returns false, this returns -1.

Returns:
the index of the element that would be returned by previous()

Implements java.util.ListIterator.

Definition at line 465 of file AbstractList.java.

      {
        checkModL();
        return position - 1;
      }

Here is the call graph for this function:

Remove from the list the element last returned by a call to next or previous (optional operation).

This method may only be called if neither add nor remove have been called since the last call to next or previous.

Exceptions:
IllegalStateExceptionif neither next or previous have been called, or if add or remove has been called since the last call to next or previous
UnsupportedOperationExceptionif this ListIterator does not support the remove operation

Implements java.util.ListIterator.

Definition at line 471 of file AbstractList.java.

      {
        checkModL();
        if (lastReturned < 0)
          throw new IllegalStateException();
        AbstractList.this.remove(lastReturned);
        size--;
        position = lastReturned;
        lastReturned = -1;
        knownMod = AbstractList.this.modCount;
      }

Here is the call graph for this function:

Replace the element last returned by a call to next or previous with a given object (optional operation).

This method may only be called if neither add nor remove have been called since the last call to next or previous.

Parameters:
othe object to replace the element with
Exceptions:
ClassCastExceptionthe object is of a type which cannot be added to this list
IllegalArgumentExceptionsome other aspect of the object stops it being added to this list
IllegalStateExceptionif neither next or previous have been called, or if add or remove has been called since the last call to next or previous
UnsupportedOperationExceptionif this ListIterator does not support the set operation

Implements java.util.ListIterator.

Definition at line 483 of file AbstractList.java.

      {
        checkModL();
        if (lastReturned < 0)
          throw new IllegalStateException();
        AbstractList.this.set(lastReturned, o);
      }

Here is the call graph for this function:


Member Data Documentation

Definition at line 413 of file AbstractList.java.

int java.util.AbstractList.lIListIterator.knownMod = AbstractList.this.modCount [private]

Definition at line 417 of file AbstractList.java.

Definition at line 419 of file AbstractList.java.

Definition at line 418 of file AbstractList.java.

Definition at line 420 of file AbstractList.java.


The documentation for this class was generated from the following file: