Packagecom.bourre.collection
Classpublic class StringIterator
ImplementsListIterator

Player version: Flash Player 9.0
Language version: ActionScript 3.0

The StringIterator class provides a convenient way to iterate through each character of a string as you could do with a List instance.

Iterations are performed from 0 to the length of the passed-in string.

See also

ListIterator.html


Protected Properties
 PropertyDefined by
  _bAdded : Boolean
StringIterator
  _bRemoved : Boolean
StringIterator
  _nGap : Number
StringIterator
  _nIndex : Number
StringIterator
  _nSize : Number
StringIterator
  _sString : String
StringIterator
Public Methods
 MethodDefined by
  
StringIterator(s:String, gap:Number = 1, i:uint = 0)
Creates a new string iterator to iterate through each character of the passed-in string.
StringIterator
  
add(o:Object):void
Inserts the specified element into the list (optional operation).
StringIterator
  
hasNext():Boolean
Returns true if the iteration has more elements.
StringIterator
  
hasPrevious():Boolean
Returns true if this list iterator has more elements when traversing the list in the reverse direction.
StringIterator
  
next():*
Returns the next element in the iteration.
StringIterator
  
nextIndex():uint
Returns the index of the element that would be returned by a subsequent call to next.
StringIterator
  
Returns the previous element in the list.
StringIterator
  
Returns the index of the element that would be returned by a subsequent call to previous.
StringIterator
  
remove():void
Removes from the underlying collection the last element returned by the iterator (optional operation).
StringIterator
  
set(o:Object):void
StringIterator
Property detail
_bAddedproperty
protected var _bAdded:Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

_bRemovedproperty 
protected var _bRemoved:Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

_nGapproperty 
protected var _nGap:Number

Player version: Flash Player 9.0
Language version: ActionScript 3.0

_nIndexproperty 
protected var _nIndex:Number

Player version: Flash Player 9.0
Language version: ActionScript 3.0

_nSizeproperty 
protected var _nSize:Number

Player version: Flash Player 9.0
Language version: ActionScript 3.0

_sStringproperty 
protected var _sString:String

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Constructor detail
StringIterator()constructor
public function StringIterator(s:String, gap:Number = 1, i:uint = 0)

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Creates a new string iterator to iterate through each character of the passed-in string.

Parameters
s:StringString iterator's target
 
gap:Number (default = 1) — gap
 
i:uint (default = 0) — iterator's start index

Throws
NullPointerException — if the string's target is null
 
IndexOutOfBoundsException — if the index is out of range
Method detail
add()method
public function add(o:Object):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Inserts the specified element into the list (optional operation). The element is inserted immediately before the next element that would be returned by next, if any, and after the next element that would be returned by previous, if any. (If the list contains no elements, the new element becomes the sole element on the list.) The new element is inserted before the implicit cursor: a subsequent call to next would be unaffected, and a subsequent call to previous would return the new element. (This call increases by one the value that would be returned by a call to nextIndex or previousIndex.)

Parameters
o:Object — the element to insert.

Throws
IllegalArgumentException — The passed-in string couldn't be added due to its length
hasNext()method 
public function hasNext():Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns
Booleantrue if the iterator has more elements.
hasPrevious()method 
public function hasPrevious():Boolean

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns true if this list iterator has more elements when traversing the list in the reverse direction. (In other words, returns true if previous would return an element rather than throwing an exception.)

Returns
Booleantrue if the list iterator has more elements when traversing the list in the reverse direction.
next()method 
public function next():*

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns the next element in the iteration. Calling this method repeatedly until the hasNext() method returns false will return each element in the underlying collection exactly once.

Returns
* — the next element in the iteration.
nextIndex()method 
public function nextIndex():uint

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns the index of the element that would be returned by a subsequent call to next. (Returns list size if the list iterator is at the end of the list.)

Returns
uint — the index of the element that would be returned by a subsequent call to next, or list size if list iterator is at end of list.
previous()method 
public function previous():*

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns the previous element in the list. This method may be called repeatedly to iterate through the list backwards, or intermixed with calls to next to go back and forth. (Note that alternating calls to next and previous will return the same element repeatedly.)

Returns
* — the previous element in the list.
previousIndex()method 
public function previousIndex():uint

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Returns the index of the element that would be returned by a subsequent call to previous. (Returns -1 if the list iterator is at the beginning of the list.)

Returns
uint — the index of the element that would be returned by a subsequent call to previous, or -1 if list iterator is at beginning of list.
remove()method 
public function remove():void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Removes from the underlying collection the last element returned by the iterator (optional operation). This method can be called only once per call to next. The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method.

set()method 
public function set(o:Object):void

Player version: Flash Player 9.0
Language version: ActionScript 3.0

Parameters
o:Object

Throws
IllegalArgumentException — The passed-in string couldn't be set due to its length