Esempio n. 1
0
    public void AddFront(Item value)
    {
        SLinkNode <Item> newNode = new SLinkNode <Item>(value);

        newNode.next = head;
        head         = newNode;
        size++;
    }
Esempio n. 2
0
    public Item RemoveFront()
    {
        if (size == 0)
        {
            throw new ListaVacia();
        }
        Item ret = head.value;

        head = head.next;
        size--;
        return(ret);
    }
    /*
     * Convertir el Linked List a un string para ser impreso en la consola
     */
    public override string ToString()
    {
        StringBuilder sb      = new StringBuilder();
        SLinkNode     curNode = head;

        while (curNode != null)
        {
            if (curNode != head)
            {
                sb.Append('\n');
            }
            sb.Append(curNode.value);
            curNode = curNode.next;
        }
        return(sb.ToString());
    }