class List
Attributes
final[RW]
inicio[RW]
Public Class Methods
new()
click to toggle source
# File lib/biblioalu0100815146/lista.rb, line 9 def initialize() @inicio = nil @final = nil end
Public Instance Methods
each() { |nil| ... }
click to toggle source
# File lib/biblioalu0100815146/lista.rb, line 90 def each if (@inicio == nil and @final == nil) yield nil elsif (@inicio == @final) yield @inicio.value else while(@inicio != nil) yield @inicio.value @inicio = @inicio.next end end end
extraer_final()
click to toggle source
# File lib/biblioalu0100815146/lista.rb, line 41 def extraer_final() if (@final == nil) return nil else aux= @final @final= final.prev return aux end end
extraer_inicio()
click to toggle source
# File lib/biblioalu0100815146/lista.rb, line 16 def extraer_inicio() if (@inicio == nil) return nil else aux = @inicio @inicio = @inicio.next return aux end end
insert_end(x)
click to toggle source
# File lib/biblioalu0100815146/lista.rb, line 52 def insert_end(x) nodo = Node.new(x,nil,nil) if(@final == nil) @final = nodo @inicio = nodo else aux = @final @final = nodo @final.prev = aux aux.next = @final end end
insert_inicio(x)
click to toggle source
# File lib/biblioalu0100815146/lista.rb, line 28 def insert_inicio(x) nodo = Node.new(x,nil,nil) if(@inicio == nil) @inicio = nodo @final = nodo else aux = @inicio @inicio = nodo @inicio.next = aux aux.prev = @inicio end end
insert_multiple(nodos)
click to toggle source
# File lib/biblioalu0100815146/lista.rb, line 68 def insert_multiple(nodos) nodos.each do |element| insert_inicio(element) end end
to_s()
click to toggle source
# File lib/biblioalu0100815146/lista.rb, line 111 def to_s output = [] i=0; while(@inicio != nil) output1 = @inicio.value.to_s output[i] = output1 @inicio = @inicio.next i = i+1 end output end
vacio()
click to toggle source
# File lib/biblioalu0100815146/lista.rb, line 76 def vacio() if(@inicio == nil) return true else return false end end