ListEnumerator Class

The ListEnumerator class lets you traverse the elements in a list.

Syntax

class ListEnumerator extends Object implements Enumerator

Run On

Called

Methods

  Method Description
Gg921804.pubmethod(en-us,AX.60).gif cancelTimeOut Cancels a previous method call to the setTimeOut method. (Inherited from Object.)
Gg921804.pubmethod(en-us,AX.60).gif current Retrieves the value that is pointed to by the enumerator.
Gg921804.pubmethod(en-us,AX.60).gif definitionString Returns a description of the enumerator.
Gg921804.pubmethod(en-us,AX.60).gif equal Determines whether the specified object is equal to the current one. (Inherited from Object.)
Gg921804.pubmethod(en-us,AX.60).gif getTimeOutTimerHandle Returns the timer handle for the object. (Inherited from Object.)
Gg921804.pubmethod(en-us,AX.60).gif handle Retrieves the handle of the class of the object. (Inherited from Object.)
Gg921804.pubmethod(en-us,AX.60).gif moveNext Determines whether the enumerator denotes a valid list element.
Gg921804.pubmethod(en-us,AX.60).gif new Initializes a new instance of the Object class. (Inherited from Object.)
Gg921804.pubmethod(en-us,AX.60).gif notify Releases the hold on an object that has called the wait method on this object. (Inherited from Object.)
Gg921804.pubmethod(en-us,AX.60).gif notifyAll Releases a lock on the object that was issued by the wait method on this object. (Inherited from Object.)
Gg921804.pubmethod(en-us,AX.60).gif objectOnServer Determines whether the object is on a server. (Inherited from Object.)
Gg921804.pubmethod(en-us,AX.60).gif owner Returns the instance that owns the object. (Inherited from Object.)
Gg921804.pubmethod(en-us,AX.60).gif reset Moves the enumerator to the start of the list.
Gg921804.pubmethod(en-us,AX.60).gif setTimeOut Sets up the scheduled execution of a specified method. (Inherited from Object.)
Gg921804.pubmethod(en-us,AX.60).gif toString Returns a description of the content of the element in the list that the enumerator is currently pointing to. (Overrides the toString Method.)
Gg921804.pubmethod(en-us,AX.60).gif usageCount Returns the current number of references, that is, the value of the reference counter, that the object has. (Inherited from Object.)
Gg921804.pubmethod(en-us,AX.60).gif wait Pauses a process. (Inherited from Object.)
Gg921804.pubmethod(en-us,AX.60).gif xml Returns an XML string that represents the current object. (Inherited from Object.)

Top

Remarks

List enumerators start before the first element in the list. You must call the ListEnumerator.moveNext method to make it point to the first element in the list.

It is best practice to use the ListEnumerator class instead of the ListIterator class, because enumerators are automatically created on the same tier as the list (when the list.getEnumerator method is called). This avoids a potential problem in code that is marked as Called from, where the iterator and list can be on separate tiers. In addition, list enumerators require less code than list iterators and therefore perform slightly better. The only situation where you have to use a list iterator is if you want to delete items from a list (use the ListIterator.delete method).

Examples

The following example creates a list of integers and puts some values into it. It then creates an enumerator, and then sets the enumerator to the first element in the list and then the second element in the list.

{ 
    List list = new List(Types::Integer); 
    ListEnumerator enumerator; 
  
    // Add some elements to the list 
    list.addEnd(1); 
    list.addEnd(2); 
    list.addStart(3); 
  
    // Set the enumerator 
    enumerator = list.getEnumerator(); 
 
    // Print a description of the list 
    print enumerator.definitionString(); 
 
    // Go to beginning of enumerator 
    enumerator.reset(); 
    //Go to the first element in the List 
    enumerator.moveNext(); 
  
    // Print contents of first and second elements 
    // First element is 3 as this was added to start of list 
    print enumerator.toString(); 
    enumerator.moveNext(); 
    print enumerator.toString(); 
    pause; 
}

Inheritance Hierarchy

Object Class
  ListEnumerator Class

See Also

List Class

ListIterator Class