//version:1.0
//author: BrianChao 
//locale : taiwan 

//StringBuffer
function StringBuffer(){
	this.array = new Array();
	this.append = StringBuffer_append;
	this.toString = StringBuffer_toString;
}

function StringBuffer_append(content){
	this.array[eval(this.array.length)] = content;	
}

function StringBuffer_toString(){
	return this.array.join("");
}

// ArrayList Object

function ArrayList(){
 this.index = -1;
 this.array = new Array(); 
 this.add = ArrayList_add; 
 this.get = ArrayList_get;   
 this.size = ArrayList_size;       
 this.remove = ArrayList_remove;            
}
function ArrayList_add(obj){
	this.index = this.index + 1;
	this.array[eval(this.index)] = obj;
}
function ArrayList_get(index){return this.array[eval(index)];}
function ArrayList_size(){return this.index+1;}
function ArrayList_remove(index){
	var j = 0;
	var arrThis = this.array; 
	var arrTemp = new Array();
	for(w=0;w<arrThis.length;w++){
		//alert(eval(index)!=eval(w))
		//alert(w)
		if (eval(index)!=eval(w)) {
			arrTemp[j] = arrThis[w];	
			j++;
		}	
	}	
	this.array = arrTemp;
	this.index = eval(j-1); 
}


// HashTable Object

function HashTable(){
 this.arrValues = new ArrayList(); 
 this.put = HashTable_put;
 this.get = HashTable_get;
 this.keys = HashTable_keys;
 this.remove = HashTable_remove;
}

function HashTable_Map(){
	var key = null;  
	var value = null; 
}

function HashTable_put(objKey,objValue){
	var isAdd = true;
	var arrThis = this.arrValues;	
	for(i=0;i<arrThis.size();i++){
		var map = arrThis.get(i);
		if (map.key==objKey){
			map.value = objValue;
			isAdd = false;
		}
	}
	if (isAdd){
		var Map = new HashTable_Map();
		Map.key = objKey;
		Map.value = objValue;
		this.arrKeys = objKey;
		this.arrValues.add(Map);
	}
}

function HashTable_get(objKey){
	var arrThis = this.arrValues;	
	for(i=0;i<arrThis.size();i++){
		var map = arrThis.get(i);
		if (map.key==objKey) return map.value;
	}
	return null;
}

function HashTable_keys(){
	var arrKeys = new Array();
	var arrThis = this.arrValues;	
	for(i=0;i<arrThis.size();i++){
		var map = arrThis.get(i);
		arrKeys[i] = map.key;
	}
	return arrKeys;	
}

function HashTable_remove(objKey){
	for(i=0;i<this.arrValues.size();i++){
		var map = this.arrValues.get(i);
		if (objKey == map.key){
			this.arrValues.remove(i);
		}
	}
}