// 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.list = list;
	this.index = list.length;
}

// Meta

DispatchIterator.__name__ = ["openfl","events","_EventDispatcher","DispatchIterator"];
DispatchIterator.prototype = {
	copy: function() {
		if(!this.isCopy) {
			this.list = this.list.slice();
			this.isCopy = true;
		}
	},
	hasNext: function() {
		if(this.index < this.list.length) {
			return true;
		} else {
			this.active = false;
			return false;
		}
	},
	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.active = true;
		this.isCopy = false;
		this.index = 0;
	}
};
DispatchIterator.prototype.__class__ = $hxClasses["openfl.events._EventDispatcher.DispatchIterator"] = DispatchIterator;

// Init



// Statics




// Export

exports.default = DispatchIterator;