⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iterator.class.js

📁 《JavaScript王者归来》examples.rar
💻 JS
字号:
# language: JSVM2

/**
 * @fileoverview js.util.Iterator class {@link http://jsvm.org/}
 * @file		Iterator.jsc
 * @author	Wan Changhua
 * @version	2.01, 10/23/05
 * @since		JSVM1.0
 */

package js.util;


/**
 * Create a new Iterator instance.
 * Inherit from JObject
 * @author	Wan Changhua
 * @version	2.01, 10/23/05
 * @extends JObject
 * @class This is the iterator class.
 * @constructor
 */

class Iterator (aArray) {

	/**
	 * @private
	 */
	var array = aArray;
	var index = 0;

	/**
	 * Returns <tt>true</tt> if the iteration has more elements.
	 * @return  <code>true</code>  if it has next;
	 *          <code>false</code> otherwise.
	 * @type boolean
	 */
	this.hasNext = function() {
		return (array.length > index);
	}
	
	/**
	 * Returns the next element in the iteration.
	 * @return  the next element in the iteration.
	 * @type Object
	 */
	this.next = function() {
		return array[index++];
	}
	
    /**
     * Returns an array containing all of the elements in this iterator
     * @type Array
     */
	this.toArray = function () {
		return array.concat([]);
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -