function KList(){
	/*
	La List est composé de nodes (noeud) (objet lier entre eux dans les 2 sens)
				
				{vers node n}   .....-[node 0]--[node 1]--[node 2]--[node 3]-..-[node n]-....   {vers node0}
				                           |         |         |         |           |
									  [nb node]  [objet]   [objet]   [objet]     [objet]
									  
			[node 0] nest pas supprimable il porte un deuxieme nom flag (drapeau).
			[node 0] à une valeur nom modifiable, contrairement aux autres nodes, car il contient le nombre d'occurence mise à jour à chaque ajout et retret.
	
	*/
	
	
	//----------------------------------------------------------
	function Node(_objet,_G,_D){
		
/*		
                                               
          __________             __________             __________
         |          |	        |          |           |          |	
   ...===|  this.G  |===========|  this    |===========|  this.D  |===...
         |__________|           |__________|           |__________|
              |                       |                      |
	          |                       |                      |
        [this.G.objet]          [this.objet]           [this.D.objet]
	  
		
	*/	
		var G;
		var D;
		var objet;
		
		//***************************************************
		//CONSTRUCTEUR
		if(_G!=null && _D!=null){
		this.G=_G;
		this.D=_D;
		}else{
		this.G=this
		this.D=this
		}
		this.objet=_objet;
		//***************************************************
	
		
		//***************************************************
		//changement du node gauche
		this.setG =function (_node){
			this.G= _node;
			}
		//***************************************************
		
		
		//***************************************************
		//changement du node gauche	
		this.setD =function (_node){
			this.D= _node;
			}
		//***************************************************
		
		
		//***************************************************
		//modification de l'objet
		this.setvalue =function (_objet){
			this.objet= _objet;
			}
		//***************************************************
		
		
		//***************************************************
		//recuperation de l'objet
		this.getvalue = function (){
			return this.objet;
			}
		//***************************************************
	
	}
	//----------------------------------------------------------		
		

	var flag ;
	var curr;
	
	
	this.flag= new Node(0,null,null);
	this.curr=this.flag;
	
	
	//***************************************************
	//l'occurance courante devient l'occurance suivante de la List;
	this.next = function (){
		this.curr=this.curr.D
		}
	//***************************************************
	
	
	//***************************************************
	//l'occurance courante devient l'occurance precedante de la List;
	this.last = function (){
		this.curr=this.curr.G
		}
	//***************************************************
	
	
	//***************************************************
	//renvois la valeur (qui peut etre un objet) de l'occurence courante;
	this.getcurrval = function(){
		return this.curr.getvalue();
		}
	//***************************************************


	//***************************************************
	this.afflist=function(){
		this.goInFlag();
		a="";
		b=0;

		this.next();
		
		while ( this.curr!=this.flag ){
			
			a=a+"\n ["+this.curr.nb+" "+this.curr.getvalue().typeobj;
			this.next();
			}		
			alert(a  );
		}
	//***************************************************


	//***************************************************
	//ajoute un occurance à la List apres l emplacement courant;
	this.add=function(_objet){
		tmpnode= new Node(_objet,this.curr,this.curr.D);
		this.curr.D.G=tmpnode;
		this.curr.D=tmpnode;
		this.curr=tmpnode;

		this.flag.setvalue(this.flag.getvalue()+1);
				this.curr.nb=this.flag.getvalue();////
	
	//	this.afflist();
		}
	//***************************************************
	
	
	//***************************************************
	//ajoute un occurance en fin de List;
	this.addAtEnd=function(_objet){
		this.goInFlag();
	this.last();
		this.add(_objet);
		}
	//***************************************************
		
		
	//***************************************************
	//enleve l'occurance courrante de la List;
	this.remove=function(){
		
		if(this.isInFlag()){
			alert ("erreur le drapeau n'est pas supprimable");
		}else{
			this.curr.G.D=this.curr.D;
			this.curr.D.G=this.curr.G;
			this.flag.setvalue(this.flag.getvalue()-1);
			}
		}
	//***************************************************
		
		
	//***************************************************
	//precise si l'objet passé en parametre fait partie de la liste
		this.present=function(obj){
			this.last();
		tmpvalue=this.curr;
		this.next();
		
		while ( this.curr!=tmpvalue && this.curr.getvalue()!=obj){
			this.next();	
			}

		return this.curr.getvalue()==obj;
		
		
			
			}
	//***************************************************
		
		
	//***************************************************
	this.removethis=function(obj){
		
		this.last();
		tmpvalue=this.curr;
		this.next();
		
		while ( this.curr!=tmpvalue && this.curr.getvalue()!=obj){
			this.next();	
			}

		if(this.curr.getvalue()==obj){
		this.remove();}
		else{
		alert("erreur l occurence n existe pas");
		}
			//	this.afflist();
		}
	//***************************************************	
	
	
	//***************************************************
	//l'occurence courante devient le drapeau
	this.goInFlag=function(){
		return (this.curr=this.flag);
		}
	//***************************************************


	//l'occurence courante est elle le drapeau ? 
	this.isInFlag=function(){
		return (this.curr==this.flag);
		}
	//***************************************************


	//***************************************************
	//nombre d'occurence
	this.size=function(){
		return this.flag.getvalue();
		}
	//***************************************************

}		
//----------------------------------------------------------
