
function HashMap()
{
	this.items = new Array();
}

HashMap.prototype.add = function(hash, object)
{
	if ( this.has(hash) )
	{
		this.remove(hash);
	}
	
	this.items.push({
		hash: hash,
		object: object	
	});
}

HashMap.prototype.has = function(hash)
{
	for ( var i = 0; i < this.items.length; i++ )
	{
		if ( this.items[i].hash == hash ) return true;
	}
	return false;
}

HashMap.prototype.get = function(hash)
{
	for ( var i = 0; i < this.items.length; i++ )
	{
		if ( this.items[i].hash == hash ) return this.items[i].object;
	}
	return null;
}

HashMap.prototype.getAll = function()
{
	var objects = new Array();
	for ( var i = 0; i < this.items.length; i++ )
	{
		objects.push(this.items[i].object);
	}
	return objects;
}

HashMap.prototype.getHashes = function()
{
	var hashes = new Array();
	for ( var i = 0; i < this.items.length; i++ )
	{
		hashes.push(this.items[i].hash);
	}
	return hashes;
}

HashMap.prototype.getCount = function()
{
	return this.items.length;
}

HashMap.prototype.isEmpty = function()
{
	return this.getCount() == 0;
}

HashMap.prototype.remove = function(hash)
{
	var newItems = new Array();
	for ( var i = 0; i < this.items.length; i++ )
	{
		if ( this.items[i].hash != hash )
		{
			newItems.push(this.items[i]);
		}
	}
	this.items = newItems;
}

HashMap.prototype.empty = function()
{
	this.items = new Array();
}
