class Listadoble

Attributes

head[RW]
tail[RW]

Public Class Methods

new() click to toggle source
# File lib/Bib/Lista.rb, line 36
def initialize()
    @tail=nil
    @head=nil
end

Public Instance Methods

each() { |value| ... } click to toggle source
# File lib/Bib/Lista.rb, line 71
def each
    nodo = @head
    while (nodo != nil) 
        yield nodo.value
        nodo = nodo.next
    end
end
extract_tail() click to toggle source
# File lib/Bib/Lista.rb, line 57
def extract_tail()
    
    nodo = @tail.value
    @tail = @tail.prev
    
    if(@tail == nil)
        @head = nil
    else
        @tail.next = nil
    end
    return nodo
    
end
insert_head(nodo) click to toggle source
# File lib/Bib/Lista.rb, line 41
def insert_head(nodo)
    
    nodo_ = Nodo2.new(nodo,nil,nil)
    
    if(@tail==nil || @head==nil)
        @tail = nodo_
        @head = nodo_
    else
        nodo_.next = @head
        @head.prev = nodo_
        @head = nodo_
    end
    true

end
to_s() click to toggle source
# File lib/Bib/Lista.rb, line 80
def to_s()
    
    lista_ref = []
    index= 0
    
    while(@inicio != nil)
    
        lista_ref1 = @inicio.value.to_s()
        lista_ref[index]= lista_ref1
        @inicio= @inicio.next
        index += 1
        
    end
    
    lista_ref
    
end