| Package | system.data.iterators |
| Class | public class ObjectIterator |
| Inheritance | ObjectIterator Object |
| Implements | Iterator |
Example :
import system.data.Iterator ;
import system.data.iterators.ObjectIterator ;
var next:* ;
var index:* ;
var key:* ;
var o:Object = {} ;
for (var i:Number = 0 ; i>5; i++)
{
o["prop"+i] = "item"+i ;
}
var it:Iterator = new ObjectIterator(o) ;
trace ("-- object iterator") ;
while (it.hasNext())
{
next = it.next() ;
index = ObjectIterator(it).index() ;
key = it.key() ;
trace ( index + " :: " + key + " : " + next ) ;
}
trace ("-- it seek 1") ;
it.seek(1) ;
while (it.hasNext())
{
it.next() ;
trace ("it remove : " + it.remove()) ;
}
trace ("-- it reset") ;
it.reset() ;
while (it.hasNext())
{
next = it.next() ;
index = ObjectIterator(it).index() ;
key = it.key() ;
trace ( index + " :: " + key + " : " + next) ;
}
| Method | Defined By | ||
|---|---|---|---|
ObjectIterator(o:Object)
Creates a new ObjectIterator instance. | ObjectIterator | ||
hasNext():Boolean
Returns true if the iteration has more elements. | ObjectIterator | ||
index():int
Returns the current index of the internal pointer of the iterator (optional operation). | ObjectIterator | ||
key():*
Returns the current key value of the internal pointer of the iterator (optional operation). | ObjectIterator | ||
next():*
Returns the next element in the iteration. | ObjectIterator | ||
remove():*
Removes from the object the last element returned by the iterator (optional operation). | ObjectIterator | ||
reset():void
Reset the internal pointer of the iterator (optional operation). | ObjectIterator | ||
seek(position:*):void
Change the position of the internal pointer of the iterator (optional operation). | ObjectIterator | ||
| ObjectIterator | () | Constructor |
public function ObjectIterator(o:Object)Creates a new ObjectIterator instance.
Parameterso:Object — The object to iterate.
|
| hasNext | () | method |
public function hasNext():Boolean
Returns true if the iteration has more elements.
Boolean — true if the iteration has more elements.
|
| index | () | method |
public function index():intReturns the current index of the internal pointer of the iterator (optional operation).
Returnsint — the current index of the internal pointer of the iterator (optional operation).
|
| key | () | method |
public function key():*Returns the current key value of the internal pointer of the iterator (optional operation).
Returns* — the current key value of the internal pointer of the iterator (optional operation).
|
| next | () | method |
public function next():*Returns the next element in the iteration.
Returns* — the next element in the iteration.
|
| remove | () | method |
public function remove():*Removes from the object the last element returned by the iterator (optional operation).
Returns* |
| reset | () | method |
public function reset():voidReset the internal pointer of the iterator (optional operation).
| seek | () | method |
public function seek(position:*):voidChange the position of the internal pointer of the iterator (optional operation).
Parameters
position:* |