// Class: openfl.events._EventDispatcher.DispatchIterator

var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this

$global.Object.defineProperty(exports, "__esModule", {value: true});

var __map_reserved = {};

// Imports

var $hxClasses = require("./../../../hxClasses_stub").default;

// Constructor

var DispatchIterator = function(list) {
	this.active = false;
	this.reset(list);
}

// Meta

DispatchIterator.__name__ = ["openfl","events","_EventDispatcher","DispatchIterator"];
DispatchIterator.prototype = {
	copy: function() {
		if(!this.isCopy) {
			this.list = this.list.slice();
			this.isCopy = true;
		}
	},
	hasNext: function() {
		return this.index < this.list.length;
	},
	next: function() {
		return this.list[this.index++];
	},
	remove: function(listener,listIndex) {
		if(this.active) {
			if(!this.isCopy) {
				if(listIndex < this.index) {
					this.index--;
				}
			} else {
				var _g1 = this.index;
				var _g = this.list.length;
				while(_g1 < _g) {
					var i = _g1++;
					if(this.list[i] == listener) {
						this.list.splice(i,1);
						break;
					}
				}
			}
		}
	},
	reset: function(list) {
		this.list = list;
		this.isCopy = false;
		this.index = 0;
	},
	start: function() {
		this.active = true;
	},
	stop: function() {
		this.active = false;
	}
};
DispatchIterator.prototype.__class__ = DispatchIterator.prototype.constructor = $hxClasses["openfl.events._EventDispatcher.DispatchIterator"] = DispatchIterator;

// Init



// Statics




// Export

exports.default = DispatchIterator;