Beispiel #1
0
        public T rechercheContent(T content)
        {
            T returnedElement = null;
            ElementPile <T> currentElementPile = null;
            Boolean         isFind             = false;

            if (taille > 0)
            {
                currentElementPile = this.nextPile;

                if (currentElementPile.compare(content))
                {
                    isFind          = true;
                    returnedElement = currentElementPile.getContent();
                }

                for (int i = 2; i <= taille; i++)
                {
                    if (!isFind)
                    {
                        currentElementPile = currentElementPile.getElement();

                        if (currentElementPile.compare(content))
                        {
                            isFind          = true;
                            returnedElement = currentElementPile.getContent();
                        }
                    }
                }
            }

            return(returnedElement);
        }
Beispiel #2
0
        public ElementPile <T> Depiler()
        {
            ElementPile <T> returnedElement = null;

            if (taille > 0)
            {
                returnedElement = this.nextPile;
                this.nextPile   = returnedElement.getElement();
                taille--;
            }
            return(returnedElement);
        }
Beispiel #3
0
        public Boolean Empiler(T newContent)
        {
            Boolean isAdded = false;

            if (!this.isPleine())
            {
                this.nextPile = new ElementPile <T>(this.nextPile, newContent);
                isAdded       = true;
                taille++;
            }
            return(isAdded);
        }
Beispiel #4
0
        public override string ToString()
        {
            string returnString = "{ ";

            if (taille > 0)
            {
                ElementPile <T> currentElementPile = this.nextPile;
                returnString += currentElementPile.getContent().ToString();

                for (int i = 2; i <= taille; i++)
                {
                    currentElementPile = currentElementPile.getElement();
                    returnString      += " " + currentElementPile.getContent().ToString();
                }
            }

            return(returnString + " }");
        }
Beispiel #5
0
 public void ViderPile()
 {
     this.nextPile = null;
     this.taille   = 0;
 }
Beispiel #6
0
 public ElementPile(ElementPile <T> element, T content)
 {
     this.element = element;
     this.content = content;
 }