org.apache.commons.collections.list

Class CursorableLinkedList.SubCursor

Enclosing Class:
CursorableLinkedList
Implemented Interfaces:
Iterator, ListIterator, OrderedIterator

protected static class CursorableLinkedList.SubCursor
extends CursorableLinkedList.Cursor

A cursor for the sublist based on LinkedSubListIterator.
Since:
Commons Collections 3.2

Field Summary

protected AbstractLinkedList.LinkedSubList
sub
The parent list

Fields inherited from class org.apache.commons.collections.list.AbstractLinkedList.LinkedListIterator

current, expectedModCount, next, nextIndex, parent

Constructor Summary

SubCursor(AbstractLinkedList.LinkedSubList sub, int index)
Constructs a new cursor.

Method Summary

void
add(Object obj)
Adds an object to the list.
boolean
hasNext()
boolean
hasPrevious()
Checks to see if there is a previous element that can be iterated to.
int
nextIndex()
Gets the index of the next element to be returned.
void
remove()
Removes the item last returned by this iterator.

Methods inherited from class org.apache.commons.collections.list.CursorableLinkedList.Cursor

add, checkModCount, close, nextIndex, nodeChanged, nodeInserted, nodeRemoved, remove

Methods inherited from class org.apache.commons.collections.list.AbstractLinkedList.LinkedListIterator

add, checkModCount, getLastNodeReturned, hasNext, hasPrevious, next, nextIndex, previous, previousIndex, remove, set

Field Details

sub

protected final AbstractLinkedList.LinkedSubList sub
The parent list

Constructor Details

SubCursor

protected SubCursor(AbstractLinkedList.LinkedSubList sub,
                    int index)
Constructs a new cursor.
Parameters:
index - the index to start from

Method Details

add

public void add(Object obj)
Adds an object to the list. The object added here will be the new 'previous' in the iterator.
Overrides:
add in interface CursorableLinkedList.Cursor
Parameters:
obj - the object to add

hasNext

public boolean hasNext()
Overrides:
hasNext in interface AbstractLinkedList.LinkedListIterator

hasPrevious

public boolean hasPrevious()
Checks to see if there is a previous element that can be iterated to.
Specified by:
hasPrevious in interface OrderedIterator
Overrides:
hasPrevious in interface AbstractLinkedList.LinkedListIterator
Returns:
true if the iterator has a previous element

nextIndex

public int nextIndex()
Gets the index of the next element to be returned.
Overrides:
nextIndex in interface CursorableLinkedList.Cursor
Returns:
the next index

remove

public void remove()
Removes the item last returned by this iterator.

There may have been subsequent alterations to the list since you obtained this item, however you can still remove it. You can even remove it if the item is no longer in the main list. However, you can't call this method on the same iterator more than once without calling next() or previous().

Overrides:
remove in interface CursorableLinkedList.Cursor

Copyright © 2001-2007 Apache Software Foundation. All Rights Reserved.