org.joda.primitives.listiterator.impl
Class ArrayCharListIterator

java.lang.Object
  extended by org.joda.primitives.listiterator.impl.ArrayCharListIterator
All Implemented Interfaces:
Iterator<Character>, ListIterator<Character>, CharIterator, PrimitiveIterator<Character>, CharListIterator, PrimitiveListIterator<Character>

public class ArrayCharListIterator
extends Object
implements CharListIterator

An iterator over an array of char values.

This class implements ListIterator allowing seamless integration with other APIs.

The iterator can be reset to the start if required. add() and remove() are unsupported, but set() is supported.

Since:
1.0
Version:
CODE GENERATED
Author:
Stephen Colebourne, Jason Tiscione

Field Summary
protected  char[] array
          The array to iterate over
protected  int cursor
          Cursor position
protected  int last
          Last returned position
 
Constructor Summary
ArrayCharListIterator(char[] array)
          Constructs an iterator over an array of char values.
 
Method Summary
 void add(char value)
          Adds the specified value to the list underlying the iterator at the current iteration index (optional operation).
 void add(Character value)
           
static ArrayCharListIterator copyOf(char[] array)
          Creates an iterator over a copy of an array of char values.
 boolean hasNext()
           
 boolean hasPrevious()
           
 boolean isModifiable()
          Checks whether the iterator can currently be modified.
 boolean isResettable()
          Checks whether the iterator can be reset.
 Character next()
           
 char nextChar()
          Gets the next value from the iterator
 int nextIndex()
           
 Character previous()
           
 char previousChar()
          Gets the previous value from the iterator.
 int previousIndex()
           
 void remove()
           
 void reset()
          Resets the iterator back to its initial state (optional operation).
 void set(char value)
          Sets the last retrieved value from the iterator (optional operation).
 void set(Character value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

array

protected final char[] array
The array to iterate over


cursor

protected int cursor
Cursor position


last

protected int last
Last returned position

Constructor Detail

ArrayCharListIterator

public ArrayCharListIterator(char[] array)
Constructs an iterator over an array of char values.

The array is assigned internally, thus the caller holds a reference to the internal state of the returned iterator. It is not recommended to modify the state of the array after construction.

Parameters:
array - the array to iterate over, must not be null
Throws:
IllegalArgumentException - if the array is null
Method Detail

copyOf

public static ArrayCharListIterator copyOf(char[] array)
Creates an iterator over a copy of an array of char values.

The specified array is copied, ensuring the original data is unaltered. Note that the class is not immutable due to the set methods.

Parameters:
array - the array to iterate over, must not be null
Throws:
IllegalArgumentException - if the array is null

isModifiable

public boolean isModifiable()
Description copied from interface: PrimitiveIterator
Checks whether the iterator can currently be modified.

Specified by:
isModifiable in interface PrimitiveIterator<Character>
Returns:
true if the modification methods of the iterator can be used

isResettable

public boolean isResettable()
Description copied from interface: PrimitiveIterator
Checks whether the iterator can be reset.

Specified by:
isResettable in interface PrimitiveIterator<Character>
Returns:
true if the object can be reset

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<Character>
Specified by:
hasNext in interface ListIterator<Character>

nextIndex

public int nextIndex()
Specified by:
nextIndex in interface ListIterator<Character>

nextChar

public char nextChar()
Description copied from interface: CharIterator
Gets the next value from the iterator

Specified by:
nextChar in interface CharIterator
Returns:
the next available value

next

public Character next()
Specified by:
next in interface Iterator<Character>
Specified by:
next in interface ListIterator<Character>

hasPrevious

public boolean hasPrevious()
Specified by:
hasPrevious in interface ListIterator<Character>

previousIndex

public int previousIndex()
Specified by:
previousIndex in interface ListIterator<Character>

previousChar

public char previousChar()
Description copied from interface: CharListIterator
Gets the previous value from the iterator.

Specified by:
previousChar in interface CharListIterator
Returns:
the previous available value

previous

public Character previous()
Specified by:
previous in interface ListIterator<Character>

add

public void add(char value)
Description copied from interface: CharListIterator
Adds the specified value to the list underlying the iterator at the current iteration index (optional operation).

Specified by:
add in interface CharListIterator
Parameters:
value - the value to add

add

public void add(Character value)
Specified by:
add in interface ListIterator<Character>

remove

public void remove()
Specified by:
remove in interface Iterator<Character>
Specified by:
remove in interface ListIterator<Character>

set

public void set(char value)
Description copied from interface: CharListIterator
Sets the last retrieved value from the iterator (optional operation).

Specified by:
set in interface CharListIterator
Parameters:
value - the value to set

set

public void set(Character value)
Specified by:
set in interface ListIterator<Character>

reset

public void reset()
Description copied from interface: PrimitiveIterator
Resets the iterator back to its initial state (optional operation).

Specified by:
reset in interface PrimitiveIterator<Character>


Copyright © 2005-2010 Joda.org. All Rights Reserved.