コード例 #1
0
    public void AddFront(Item value)
    {
        SLinkNode <Item> newNode = new SLinkNode <Item>(value);

        newNode.next = head;
        head         = newNode;
        size++;
    }
コード例 #2
0
    public Item RemoveFront()
    {
        if (size == 0)
        {
            throw new ListaVacia();
        }
        Item ret = head.value;

        head = head.next;
        size--;
        return(ret);
    }
コード例 #3
0
    /*
     * 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());
    }