// Class: openfl.utils._Dictionary.FloatMap

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;
var $import = require("./../../../import_stub").default;
function haxe_IMap() {return require("./../../../haxe/IMap");}
function HxOverrides() {return require("./../../../HxOverrides");}

// Constructor

var FloatMap = function() {
	this.floatKeys = [];
	this.values = [];
}

// Meta

FloatMap.__name__ = ["openfl","utils","_Dictionary","FloatMap"];
FloatMap.__interfaces__ = [(haxe_IMap().default)];
FloatMap.prototype = {
	exists: function(key) {
		return this.indexOf(key) > -1;
	},
	get: function(key) {
		var ind = this.indexOf(key);
		if(ind > -1) {
			return this.values[ind];
		} else {
			return null;
		}
	},
	keys: function() {
		return (HxOverrides().default).iter(this.floatKeys.slice());
	},
	iterator: function() {
		return (HxOverrides().default).iter(this.values.slice());
	},
	remove: function(key) {
		var ind = this.indexOf(key);
		if(ind > -1) {
			this.floatKeys.splice(ind,1);
			this.values.splice(ind,1);
			return true;
		}
		return false;
	},
	set: function(key,value) {
		this.insertSorted(key,value);
	},
	indexOf: function(key) {
		var len = this.floatKeys.length;
		var startIndex = 0;
		var endIndex = len - 1;
		if(len == 0) {
			return -1;
		}
		var midIndex = 0;
		while(startIndex < endIndex) {
			midIndex = Math.floor((startIndex + endIndex) / 2);
			if(this.floatKeys[midIndex] == key) {
				return midIndex;
			} else if(this.floatKeys[midIndex] > key) {
				endIndex = midIndex - 1;
			} else {
				startIndex = midIndex + 1;
			}
		}
		if(this.floatKeys[startIndex] == key) {
			return startIndex;
		} else {
			return -1;
		}
	},
	insertSorted: function(key,value) {
		var len = this.floatKeys.length;
		var startIndex = 0;
		var endIndex = len - 1;
		if(len == 0) {
			this.floatKeys.push(key);
			this.values.push(value);
			return;
		}
		var midIndex = 0;
		while(startIndex < endIndex) {
			midIndex = Math.floor((startIndex + endIndex) / 2);
			if(this.floatKeys[midIndex] == key) {
				this.values[midIndex] = value;
				return;
			} else if(this.floatKeys[midIndex] > key) {
				endIndex = midIndex - 1;
			} else {
				startIndex = midIndex + 1;
			}
		}
		if(this.floatKeys[startIndex] > key) {
			this.floatKeys.splice(startIndex,0,key);
			this.values.splice(startIndex,0,value);
		} else if(this.floatKeys[startIndex] < key) {
			this.floatKeys.splice(startIndex + 1,0,key);
			this.values.splice(startIndex + 1,0,value);
		} else {
			this.values[startIndex] = value;
		}
	},
	toString: function() {
		return this.values.toString();
	}
};
FloatMap.prototype.__class__ = FloatMap.prototype.constructor = $hxClasses["openfl.utils._Dictionary.FloatMap"] = FloatMap;

// Init



// Statics




// Export

exports.default = FloatMap;