org.apache.commons.collections.primitives.adapters
Class ListIteratorShortListIterator

java.lang.Object
  |
  +--org.apache.commons.collections.primitives.adapters.ListIteratorShortListIterator
All Implemented Interfaces:
ShortIterator, ShortListIterator

public class ListIteratorShortListIterator
extends Object
implements ShortListIterator

Adapts a Number-valued ListIterator to the ShortListIterator interface.

This implementation delegates most methods to the provided ShortListIterator implementation in the "obvious" way.

Since:
Commons Primitives 1.0
Version:
$Revision: 1.3 $ $Date: 2003/10/16 20:49:39 $

Constructor Summary
ListIteratorShortListIterator(ListIterator iterator)
          Creates an ShortListIterator wrapping the specified ListIterator.
 
Method Summary
 void add(short element)
          Inserts the specified element into my underlying collection (optional operation).
 boolean hasNext()
          Returns true iff I have more elements when traversed in the forward direction.
 boolean hasPrevious()
          Returns true iff I have more elements when traversed in the reverse direction.
 short next()
          Returns the next element in me when traversed in the forward direction.
 int nextIndex()
          Returns the index of the element that would be returned by a subsequent call to next(), or the number of elements in my iteration if I have no next element.
 short previous()
          Returns the next element in me when traversed in the reverse direction.
 int previousIndex()
          Returns the index of the element that would be returned by a subsequent call to previous(), or -1 if I have no previous element.
 void remove()
          Removes from my underlying collection the last element returned by next() or previous() (optional operation).
 void set(short element)
          Replaces in my underlying collection the last element returned by next() or previous() with the specified value (optional operation).
static org.apache.commons.collections.primitives.ShortListIterator wrap(ListIterator iterator)
          Create an ShortListIterator wrapping the specified ListIterator.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListIteratorShortListIterator

public ListIteratorShortListIterator(ListIterator iterator)
Creates an ShortListIterator wrapping the specified ListIterator.

See Also:
wrap(java.util.ListIterator)
Method Detail

wrap

public static org.apache.commons.collections.primitives.ShortListIterator wrap(ListIterator iterator)
Create an ShortListIterator wrapping the specified ListIterator. When the given iterator is null, returns null.

Parameters:
iterator - the (possibly null) ListIterator to wrap
Returns:
an ShortListIterator wrapping the given iterator, or null when iterator is null.

nextIndex

public int nextIndex()
Description copied from interface: ShortListIterator
Returns the index of the element that would be returned by a subsequent call to ShortListIterator.next(), or the number of elements in my iteration if I have no next element.

Specified by:
nextIndex in interface ShortListIterator
Returns:
the index of the next element in me

previousIndex

public int previousIndex()
Description copied from interface: ShortListIterator
Returns the index of the element that would be returned by a subsequent call to ShortListIterator.previous(), or -1 if I have no previous element.

Specified by:
previousIndex in interface ShortListIterator
Returns:
the index of the previous element in me

hasNext

public boolean hasNext()
Description copied from interface: ShortListIterator
Returns true iff I have more elements when traversed in the forward direction. (In other words, returns true iff a call to ShortListIterator.next() will return an element rather than throwing an exception.

Specified by:
hasNext in interface ShortListIterator
Returns:
true iff I have more elements when traversed in the forward direction

hasPrevious

public boolean hasPrevious()
Description copied from interface: ShortListIterator
Returns true iff I have more elements when traversed in the reverse direction. (In other words, returns true iff a call to ShortListIterator.previous() will return an element rather than throwing an exception.

Specified by:
hasPrevious in interface ShortListIterator
Returns:
true iff I have more elements when traversed in the reverse direction

next

public short next()
Description copied from interface: ShortListIterator
Returns the next element in me when traversed in the forward direction.

Specified by:
next in interface ShortListIterator
Returns:
the next element in me

previous

public short previous()
Description copied from interface: ShortListIterator
Returns the next element in me when traversed in the reverse direction.

Specified by:
previous in interface ShortListIterator
Returns:
the previous element in me

add

public void add(short element)
Description copied from interface: ShortListIterator
Inserts the specified element into my underlying collection (optional operation). The element is inserted immediately before the next element that would have been returned by ShortListIterator.next(), if any, and immediately after the next element that would have been returned by ShortListIterator.previous(), if any.

The new element is inserted immediately before the implied cursor. A subsequent call to ShortListIterator.previous() will return the added element, a subsequent call to ShortListIterator.next() will be unaffected. This call increases by one the value that would be returned by a call to ShortListIterator.nextIndex() or ShortListIterator.previousIndex().

Specified by:
add in interface ShortListIterator
Parameters:
element - the value to be inserted

set

public void set(short element)
Description copied from interface: ShortListIterator
Replaces in my underlying collection the last element returned by ShortListIterator.next() or ShortListIterator.previous() with the specified value (optional operation).

Specified by:
set in interface ShortListIterator
Parameters:
element - the value to replace the last returned element with

remove

public void remove()
Description copied from interface: ShortListIterator
Removes from my underlying collection the last element returned by ShortListIterator.next() or ShortListIterator.previous() (optional operation).

Specified by:
remove in interface ShortListIterator


Copyright © 2002-2004 Apache Software Foundation. All Rights Reserved.