// -------------------------------------------------------
// Biyn Development, LLC
// -------------------------------------------------------
// Copyright (c) 2006 all rights reserved
// -------------------------------------------------------
// multimap.js
// -------------------------------------------------------
// utilizes prototype.js
// -------------------------------------------------------

// -------------------
// MultiNode
// -------------------
var MultiNode = Class.create();
MultiNode.prototype = 
{
	initialize: function(key)
	{
		this.key = key;
		this.array = [];
	}
}

// -------------------
// MultiMap
// -------------------
var MultiMap = Class.create();
Object.extend(MultiMap.prototype, Enumerable);
Object.extend(MultiMap.prototype, 
{
	initialize: function()
	{
		this.container = null;
		this.selectors = [];
		this.array = [];
	},
	
	_each: function(iterator)
	{
	    for (key in this.array)
	    {
			if(typeof this.array[key] == 'function')
				continue;
			
	    	var node = this.array[key];
	    	if(node == null
	    	|| node == 'undefined')
	    		continue;
	    	
	    	for(var i = 0; i < node.array.length; ++i)
	    	{
				iterator(node.array[i]);
	    	}
	    }
	},
	
	add: function(key, value)
	{
		var node = this.array[key];
		if(node == null
		|| node == 'undefined')
		{
			this.array[key] = new MultiNode(key);
			node = this.array[key];
		}
		
		node.array[node.array.length] = value;
	}
});
