You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.


TOC PREV NEXT INDEX

Embedding Gecko API


nsISimpleEnumerator


This interface is used to enumerate over elements defined by its implementor. Although hasMoreElements can be called independently of getNext, getNext must be preceded by a call to hasMoreElements. There is no way to "reset" an enumerator once it has been obtained. This interface is scriptable.

Methods
hasMoreElements

Determines whether or not the enumerator has any elements that can be returned via getNext. This method is generally used to determine whether or not to initiate or continue iteration over the enumerator, though it can be called without subsequent getNext calls. This does not affect internal state of enumerator.

Syntax:

boolean nsISimpleEnumerator::hasMoreElements() 

Parameters:

None.

nsresult:

PR_TRUE if there are remaining elements in the enumerator.
PR_FALSE if there are no more elements in the enumerator.
getNext

Called to retrieve the next element in the enumerator. The "next" element is the first element upon the first call. Must be preceded by a call to hasMoreElements which returns PR_TRUE. This method is generally called within a loop to iterate over the elements in the enumerator.

Syntax:

nsISupports nsISimpleEnumerator::getNext() 

Parameters:

None.

nsresult:

NS_OK if the call succeeded in returning a non-null value.
NS_ERROR_FAILURE if there are no more elements to enumerate.

Written by:Ellen Evans | Comments, questions, complaints? Bug 143387
TOC PREV NEXT INDEX