Beispiel #1
0
        public Boolean Ajouter(T newContent)
        {
            Boolean isAdded = false;
            int     i       = 1;

            if (element != null)
            {
                ElementListeSimple <T> elementScope = this.element;

                while (i <= taille)
                {
                    if (elementScope.getElement() == null)
                    {
                        elementScope.setElement(new ElementListeSimple <T>(null, newContent));
                        isAdded = true;
                    }

                    elementScope = elementScope.getElement();
                    i++;
                }
                ;
            }
            else
            {
                this.element = new ElementListeSimple <T>(null, newContent);
                isAdded      = true;
            }

            taille++;
            return(isAdded);
        }
Beispiel #2
0
        public ElementListeSimple <T> Supprimer(T content)
        {
            ElementListeSimple <T> returnedElement = null;
            int     i         = 1;
            Boolean isRemoved = false;

            if (element != null)
            {
                ElementListeSimple <T> previousElementScope = null;
                ElementListeSimple <T> elementScope         = this.element;

                do
                {
                    if (elementScope.compare(content))
                    {
                        returnedElement = elementScope;


                        if (previousElementScope == null)
                        {
                            this.element = elementScope.getElement();
                        }
                        else
                        {
                            if (elementScope.getElement() == null)
                            {
                                previousElementScope.setElement(null);
                            }
                            else
                            {
                                previousElementScope.setElement(elementScope.getElement());
                            }
                        }

                        isRemoved = true;
                        taille--;
                    }
                    else
                    {
                        previousElementScope = elementScope;
                        elementScope         = elementScope.getElement();
                    }

                    i++;
                } while (i <= taille && !isRemoved);
            }

            return(returnedElement);
        }
Beispiel #3
0
        public override string ToString()
        {
            string returnString = "{ ";

            if (taille > 0)
            {
                ElementListeSimple <T> currentElementPile = this.element;
                returnString += currentElementPile.getContent().ToString();
                for (int i = 2; i <= taille; i++)
                {
                    currentElementPile = currentElementPile.getElement();
                    returnString      += " " + currentElementPile.getContent().ToString();
                }
            }

            return(returnString + " }");
        }
Beispiel #4
0
 public void ViderFile()
 {
     this.element = null;
     taille       = 0;
 }
 public void setElement(ElementListeSimple <T> element)
 {
     this.element = element;
 }
 public ElementListeSimple(ElementListeSimple <T> element, T content)
 {
     this.element = element;
     this.content = content;
 }