枚举管理

/wiki/api/name/gb.getenum Returns the current enumeration state.
/wiki/api/name/gb.listenum Lists all enumerators that enumerate a specified 对象.
/wiki/api/name/gb.nextenum Returns the next enumerator.
/wiki/api/name/gb.stopallenum Stops all enumerators that enumerate a specified object.
/wiki/api/name/gb.stopenum Stops the current enumeration.

Overview

Enumerations are managed in the _next special 方法.

This method is called at the start of the enumeration, and at each loop iteration, to retrieve the first or the next element.

Enumeration State

/wiki/api/name/gb.getenum gives you a pointer to a enumeration buffer. Use this buffer to store the state of the enumeration. You can store up to 16 bytes into this buffer.

Note that the buffer is initialized with zeros at the beginning of the enumeration, so that you can detect when _next is called at the start of the enumeration.

When the end of the enumeration is reached, use the /wiki/api/name/gb.stopenum function to warn the interpreter, and returns immediately from the implementation function.

Updating Enumeration State

If you destroy one element of the enumeration, you must use /wiki/api/name/gb.listenum and /wiki/api/name/gb.nextenum to update the state of current iterators.

If you entirely clear the enumerable 对象, then you must use /wiki/api/name/gb.stopallenum to stop all current iterators.