/*************************************************
* Auteur MORAND Sébastien						 *
* Création 2008									 *
* http://sebastien-morand.com					 *
**************************************************/

/* class pile */

function pile ()
	{
	this.lapile = new Array();
	this.taille_pile = 0;
	}
	
pile.prototype.ajouter = function(objet)
	{
	this.lapile[this.taille_pile] = objet; 
	this.taille_pile++;
	if(this.taille_pile == 1)
		{
		connect.envoyer(objet);
		}
	}

pile.prototype.afficher_pile = function()
	{
	var html = 'taille pile : ' + this.taille_pile + "<br /><br />---<br />";
	var i;
	for(i=this.taille_pile-1; i>=0; i--)
		{
		html = html + "|" + this.lapile[i].div + "|<br />---<br />";
		}
	html = html + '<br />/\\<br /> |';
	return html;
	}
	
pile.prototype.descendre_pile = function()
	{
	if(this.taille_pile > 0)
		{
		var i;
		var j = 0;
		for(i=0;i<this.taille_pile-1;i++)
			{
			j=i+1;
			this.lapile[i] = this.lapile[j];
			}
		delete this.lapile[this.taille_pile];
		this.taille_pile--;
		if(this.taille_pile > 0)
			{
			connect.envoyer(this.lapile[0]);
			}
		}
	}
