
	function Map() {

		this.map 	= new Object();
		this.mapedKeys 	= new Array();

	}
	
	Map.prototype.get 	= function (key) {
			var result = null
			if (typeof(key) == "number") {
				//Convert Index to get
				result = this.map[this.mapedKeys[key]];
			}
			else {
				result = this.map[key];
			}
			return result;
		};	
	Map.prototype.put 	= function(key, value) {
			if (typeof(key) != "string" || key.length == 0) {
				return null;
			}
			var result = this.map[key];
			this.map[key] = value;
			this.mapedKeys[this.mapedKeys.length] = key
			return result;			
		};

	Map.prototype.exists = function(key) {

			if (this.map == null) {
				return false;
			}	

			if (typeof(key) == "number") {
				if (this.mapedKeys[key]) {
					return (typeof(this.map[this.mapedKeys[key]]) != "undefined");
				}
			}
			else {
				return (typeof(this.map[key])!= "undefined");
			}	
		}

	Map.prototype.remove = function(key) {

			var result = null;
			if (typeof(key) == "number") {
				var aux = this.mapedKeys[key]
				if (aux) {
					result = this.map[aux];
					this.map[aux] = null
					this.mapedKeys[key] = null;
					
				}
			}
			else {
				if (this.exists(key)) {
					result = this.map[key];
					this.map[key] = null;
					for (i = 0; i < this.mapedKeys.length; i++) {
						if (this.mapedKeys[i] == key) {
							this.mapedKeys[i] = null;
							break;
						}
					}
				}
				else {
					result = null;
				}	
			}
			this.remap();
			return result;
		}

		//ReCreates a new Map free of garbage
	Map.prototype.remap = function() {
			var intgets = 0;
			var oldMapedKeys = this.mapedKeys;
			this.mapedKeys = new Array();
			var oldMap = this.map;
			this.map  = new Object();
			
			for (i = 0; i < oldMapedKeys.length; i ++) {
				var aux = oldMapedKeys[i];
				if (aux != null) {
					this.mapedKeys[intgets ++] = aux;
					this.map[aux] = oldMap[aux];
				}			
			}
			delete oldMapedKeys;
			delete arrTemp;
		}
		
	Map.prototype.length = function () {
			return this.mapedKeys.length;
		}		
	