class List

Attributes

head[RW]
tail[RW]

Public Class Methods

new(head) click to toggle source
# File linkedlist.rb, line 21
def initialize(head)


   @head = head
   @tail = head
    
    
end

Public Instance Methods

each() { |value| ... } click to toggle source
# File linkedlist.rb, line 87
def each

   actual = @tail

        while actual != nil
           yield actual.value
           actual = actual.siguiente
        end

end
insert_head(nodo) click to toggle source
# File linkedlist.rb, line 30
def insert_head(nodo)

        
        aux = @head
        
        @head.siguiente = nodo
        @head = @head.siguiente
        @head.previo = aux
        
        
end
insert_tail(nodo) click to toggle source
# File linkedlist.rb, line 42
def insert_tail(nodo)
        
        aux = @tail
        @tail = nodo
        aux.previo = @tail
        @tail.siguiente = aux

end
print() click to toggle source
remove_head() click to toggle source
# File linkedlist.rb, line 51
def remove_head

        aux = @head
        @head = @head.previo
        return aux.value
        #puts @head.value
        
                
        
end
remove_tail() click to toggle source
# File linkedlist.rb, line 76
def remove_tail

        actual = @tail
        if @tail.siguiente != nil
        @tail = @tail.siguiente
        end
        return actual.value


end