예제 #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);
        }
예제 #2
0
        public ElementPile <T> Depiler()
        {
            ElementPile <T> returnedElement = null;

            if (taille > 0)
            {
                returnedElement = this.nextPile;
                this.nextPile   = returnedElement.getElement();
                taille--;
            }
            return(returnedElement);
        }
예제 #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);
        }
예제 #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 + " }");
        }
예제 #5
0
 public void ViderPile()
 {
     this.nextPile = null;
     this.taille   = 0;
 }
예제 #6
0
 public ElementPile(ElementPile <T> element, T content)
 {
     this.element = element;
     this.content = content;
 }