//<![CDATA[
/*----------------------------------------------------------------------------
 *  ÆÄÀÏ¸í : ArrayList.js
 *  ¼³¸í : ¿¬°ü°Ë»ö¾î °ü·ÃÆÄÀÏ(JS)
 *  ÀÛ¼ºÀÚ : ºí·Î±×¿¡¼­ ÆÛ¿Â °Í ÀÓ
 *  ÃÖÃÊÀÛ¼ºÀÏ : 2010-07-26
 *--------------------------------------------------------------------------*/

/*

	¾î·¹ÀÌ¸®½ºÆ®
	ÀÚ¹Ù¿¡¼­ÀÇ ¾î·¹ÀÌ ¸®½ºÆ®¿Í ºñ½ÁÇÑ ±â´É

*/

//¾î·¹ÀÌ ¸®½ºÆ®
var ArrayList = function(){
	this.List = new Array();
	this.index = -1;
	this.length = 0;
}
ArrayList.prototype = {
	//ÇöÀç³ëµå¼ÂÆÃ(¿¤¸®¸ÕÆ®)	=>	TF ¹ÝÈ¯
	setIndexEl : function(el){
		for (var i=0; i<this.size(); i++){
			if(this.List[i]==el){
				this.index = i;
				return true;
			}
		}
		return false;
	},
	//ÇöÀç³ëµå¼ÂÆÃ(index)	=>	TF ¹ÝÈ¯
	setIndex : function(index){
		if(0 <= index && index < this.size()){
			this.index = index;
			return true;
		}
		return false;
	},
	//ÇöÀçÀÎµ¦½º ¹ÝÈ¯
	getIndex : function(){
		return this.index;
	},
	//ÀÌÀü³ëµå°¡´É¿©ºÎ	=>	TF
	isPrev : function(){
		if(this.index > 0){
			return true;
		}
		return false;
	},
	//´ÙÀ½³ëµå°¡´É¿©ºÎ	=>	TF
	isNext : function(){
		if(this.index+1 < this.size()){
			return true;
		}
		return false;
	},
	//ÇöÀç³ëµå ¹ÝÈ¯		=>	³ëµå
	getCur : function(){
		return this.List[this.index];
	},
	//ÀÌÀü³ëµå¹ÝÈ¯	=>	³ëµå or False
	getPrev : function(){
		if(this.index > 0){
			this.index = this.index-1;
			return this.List[this.index];
		}
		return false;
	},
	//´ÙÀ½³ëµå¹ÝÈ¯
	getNext : function(){
		if(this.index+1 < this.size()){
			this.index = this.index+1;
			return this.List[this.index];
		}
		return false;
	},
	//ÀÚ·áÀÔ·Â(¿¤¸®¸ÕÆ®) => ÀÔ·Â ÈÄ Å©±â ¹ÝÈ¯
	add : function(el){
		this.length = this.List.push(el);
		return this.size()-1;
	},
	//ÀÚ·á»èÁ¦(¿¤¸®¸ÕÆ®) => »èÁ¦ ÈÄ Å©±â ¹ÝÇÑ
	remove : function(el){
		var tempList = new Array();
		for (var i=0; i<this.size(); i++){
			if(this.List[i]!=el){
				tempList.push(this.List[i]);
			}
		}
		this.List = tempList;
		this.length = tempList.length;
		return this.size();
	},
	//ÀÚ·á¾ò±â(index)
	getList : function(index){
		return this.List[index];
	},
	//¸¶Áö¸·³ëµåÀÎµ¦½º¹ÝÈ¯
	getLastIndex : function(){
		return this.List[this.length-1];
	},
	//ÇöÀçÅ©±â¹ÝÈ¯
	size : function(){
		return this.length;
	}
}

//]]>
