Method: DlinkedList#insertHead

Defined in:
lib/DlinkedList.rb

#insertHead(value) ⇒ Object

Inserta por la cabeza de la lista un nodo

Parameters:

Recive un valor o dato que se quiera insertar

Returns:

No retorna nada



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/DlinkedList.rb', line 56

def insertHead(value)
    
    n = Node.new(value)
    
    if @head.nil?
        
        @head = n
        @tail = @head
        
    else
        
        @head.next = n
        n.prev = @head
        @head = n
        
    end
    
end