﻿function Map(){
	this.map=new Array();
	this.put=function(key,value){	
　　	for (var i=0;i<this.map.length;i++){
	　　	if (this.map[i]._key==key){
				var obj=this.map.splice(i,1);
	　　	}
　　	}		

		this.map.push({_key:key,_value:value});
	}
	
	this.get=function(key){
		try{
			for(var i=0;i<this.map.length;i++){
				if(this.map[i]._key==key){
					return this.map[i]._value;
				}
			}
		}catch(e){
			alert(e);
			return null;
		}
		return null;
	}
	
	this.getObj=function(index){
	　　var obj;
		try{
	　　	for (var i=0;i<this.map.length;i++){
		　　	if (i==index){
				　　obj=this.map[i];		　　		
		　　	}
				return obj;
	　　	}
	　　}catch(e){
		　　alert(e);
			return null;
	　　}
	　　return null;			
	}
			
	this.remove=function(key){
	　　try{
	　　	for (var i=0;i<this.map.length;i++){
		　　	if (this.map[i]._key==key){
		　　		var obj=this.map.splice(i,1);
		　　		return obj;
		　　	}
	　　	}
	　　}catch(e){
		　　alert(e);
			return null;
	　　}
	　　return null;	
	}
	
	this.size=function(){
		return this.map.length;
	}
	
	this.containsKey=function(key){
	　　try{
	　　	for (var i=0;i<this.map.length;i++){
		　　	if (this.map[i]._key==key){		　　		
		　　		return true;
		　　	}
	　　	}
	　　}catch(e){
		　　alert(e);
			return false;
	　　}
	　　return false;			
	}
	
	this.containsValue=function(value){
	　　try{
	　　	for (var i=0;i<this.map.length;i++){
		　　	if (this.map[i]._value==value){		　　		
		　　		return true;
		　　	}
	　　	}
	　　}catch(e){
		　　alert(e);
			return false;
	　　}
	　　return false;		
	}
	
	this.isEmpty=function(){
		if(this.map.length==0){
			return true;
		}else{
			return false;
		}
	}
	
	this.values=function(){
		var result=new Array();
	　　try{
	　　	for (var i=0;i<this.map.length;i++){
		　　		result.push(this.map[i]._value);		　　		
	　　	}
	　　}catch(e){
		　　alert(e);
			return null;
	　　}
	　　return result;		
	}
	
	this.keys=function(){
		var result=new Array();
	　　try{
	　　	for (var i=0;i<this.map.length;i++){
		　　		result.push(this.map[i]._key);		　　		
	　　	}
	　　}catch(e){
		　　alert(e);
			return null;
	　　}
	　　return result;		
	}	
	
	this.clear=function(){
	　　try{
　　		this.map.splice(0,this.map.length);
	　　}catch(e){
		　　alert(e);
			return;
	　　}
	　　return;			
	}	
	
	this.isMap=function(){
		return true;
	}
}



