Ejemplo n.º 1
0
 void Inicialization(T val)
 {
     first = new NodoPractica <T>();
     last  = new NodoPractica <T>();
     first.SetValue(val);
     last = first;
 }
Ejemplo n.º 2
0
    public void SetChild(T newChildren)
    {
        NodoPractica <T> newNode = new NodoPractica <T>();

        newNode.SetValue(newChildren);
        next = newNode;
    }
Ejemplo n.º 3
0
 public void Add(T element)
 {
     if (first == null)
     {
         Inicialization(element);
     }
     else
     {
         last.SetChild(element);
         last = last.GetChild();
     }
 }
Ejemplo n.º 4
0
    public void Remove(T element)
    {
        if (first == null)
        {
            return;
        }
        NodoPractica <T> elementToRemove = null;
        NodoPractica <T> elementBefore   = first;

        NodoPractica <T> current = first;

        if (first.GetValue().Equals(element))
        {
            first = first.next;
            last  = first;
            return;
        }

        while (current.next != null)
        {
            if (current.next.GetValue().Equals(element))
            {
                elementBefore   = current;
                elementToRemove = current.next;
                break;
            }
            current = current.next;
        }
        if (elementToRemove != null)
        {
            elementBefore.next = elementToRemove.next;
            if (elementToRemove.next != null)
            {
                last = elementToRemove.next;
            }
        }
        else
        {
            Debug.Log("No se encontro");
        }
    }