/*****************************************************************************
 *
 * File     : Hashtable.js
 * 
 * Project  : WMS Viewer Client
 * 
 * Contents : 
 *
 * Author: Milan Trninic
 *
 * Copyright 1999-2005 Galdos Systems, Inc.
 * All rights reserved.
 * 
 ***|***************************|***********************|*******************|*/

/************************************************************************
*
*	function:	Hashtable
*
*	purpose:	Constructor
*
*************************************************************************/
function Hashtable()
{
	// method assignments
	this.init = Hashtable.init;
	this.get = Hashtable.get;
	this.put = Hashtable.put;
	this.remove = Hashtable.remove;
	this.removeAll = Hashtable.removeAll;
	this.contains = Hashtable.contains;
	this.getSize = Hashtable.getSize;
	this.getKeys = Hashtable.getKeys;
	this.getValues = Hashtable.getValues;

	// instance field declarations
	this._keys;
	this._values;

	// initialization
	this.init();
}

/************************************************************************
*
*	function:	init
*
*	purpose:	
*
*************************************************************************/
function Hashtable.init()
{
	this._keys = new Collection();
	this._values = new Collection();
}

/************************************************************************
*
*	function:	get
*
*	purpose:	
*
*************************************************************************/
function Hashtable.get(key)
{
	var index = this._keys.indexOf(key);
	if (index == -1) return null;
	return this._values.get(index);
}

/************************************************************************
*
*	function:	put
*
*	purpose:	
*
*************************************************************************/
function Hashtable.put(key, value)
{
	this.remove(key);
	this._keys.add(key);
	this._values.add(value);
}

/************************************************************************
*
*	function:	remove
*
*	purpose:	
*
*************************************************************************/
function Hashtable.remove(key)
{
	var index = this._keys.indexOf(key);
	if (index != -1)
	{
		this._keys.removeAt(index);
		this._values.removeAt(index);
	}
}

/************************************************************************
*
*	function:	removeAll
*
*	purpose:	
*
*************************************************************************/
function Hashtable.removeAll()
{
	this._keys.removeAll();
	this._values.removeAll();
}

/************************************************************************
*
*	function:	contains
*
*	purpose:	
*
*************************************************************************/
function Hashtable.contains(object)
{
	var index = this._values.indexOf(object);
	return (index == -1 ? false : true);
}

/************************************************************************
*
*	function:	getSize
*
*	purpose:	
*
*************************************************************************/
function Hashtable.getSize()
{
	return this._keys.getSize();
}

/************************************************************************
*
*	function:	getKeys
*
*	purpose:	
*
*************************************************************************/
function Hashtable.getKeys()
{
	return this._keys;
}

/************************************************************************
*
*	function:	getValues
*
*	purpose:	
*
*************************************************************************/
function Hashtable.getValues()
{
	return this._values;
}

