StringIterator
| Kind of class: | public class |
|---|---|
| Package: | com.bourre.collection |
| Inherits from: | none |
| Implements: | |
| Author: | Cédric Néhémie |
| Classpath: | com.bourre.collection.StringIterator |
| File last modified: | Monday, 24 November 2008, 11:36:49 |
The
to iterate through each character of a string as you could do with
a
StringIterator class provides a convenient wayto 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:
Summary
Constructor
- StringIterator (s:String, gap:Number = 1, i:uint = 0)
- Creates a new string iterator to iterate through
Instance methods
- hasNext : Boolean
- next : *
- remove : void
- add (o:Object) : void
- hasPrevious : Boolean
- nextIndex : uint
- previous : *
- previousIndex : uint
- set (o:Object) : void
Constructor
StringIterator
public function StringIterator (
s:String,
gap:Number = 1,
i:uint = 0)
Creates a new string iterator to iterate through
each character of the passed-in string.
each character of the passed-in string.
Parameters:
s :
String iterator's targetgap:
i :
iterator's start index
Throws:
- {VISDOC_LINK_0}
NullPointerException— if the string's target is null - {VISDOC_LINK_1}
IndexOutOfBoundsException— if the index is out of range
Instance methods
add
public function add (
o:Object) : void
Parameters:
o:
the element to insert.
#Throws:
- {VISDOC_LINK_0}
IllegalArgumentException— The passed-in string couldn't be added due to its length
Specified by:
hasNext
public function hasNext (
) : Boolean
Returns:
- #
StringIteratorif the iterator has more elements.
Specified by:
hasPrevious
public function hasPrevious (
) : Boolean
Returns:
- {VISDOC_CODE_BLOCK_15} if the list iterator has more elements when#
traversing the list in the reverse direction.
Specified by:
next
public function next (
) : *
nextIndex
public function nextIndex (
) : uint
Returns:
- 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.
Specified by:
previous
public function previous (
) : *
previousIndex
public function previousIndex (
) : uint
Returns:
- the index of the element that would be returned#
by a subsequent call to previous, or {VISDOC_CODE_BLOCK_18} if list iterator is at beginning of list.
Specified by:
remove
public function remove (
) : void
Specified by:
set
public function set (
o:Object) : void
Parameters:
o:
the element with which to replace the last
element returned by next or previous.
#element returned by next or previous.
Throws:
- {VISDOC_LINK_0}
IllegalArgumentException— The passed-in string couldn't be set due to its length
Specified by: