class Lista_doble
Attributes
head[RW]
tail[RW]
Public Class Methods
new()
click to toggle source
# File lib/biblio/list.rb, line 46 def initialize() @head = nil @tail = nil end
Public Instance Methods
each() { |value| ... }
click to toggle source
# File lib/biblio/list.rb, line 79 def each enum = @head while (enum != nil) yield enum.value enum = enum.next end end
empty?()
click to toggle source
# File lib/biblio/list.rb, line 41 def empty? @head == nil end
extraer_elemento()
click to toggle source
# File lib/biblio/list.rb, line 69 def extraer_elemento @node = Node_.new(nil, @head.value, nil) @head = @head.next @head.prev = nil return @node end
insertar_elemento(node)
click to toggle source
# File lib/biblio/list.rb, line 52 def insertar_elemento(node) @node = Node_.new(nil, node, nil) if @tail == nil @head = @node @tail = @node #@node else @node.next = @head @head.prev = @node @head = @node #@node end end
ordenar!()
click to toggle source
# File lib/biblio/list.rb, line 87 def ordenar! cambio = true while cambio cambio = false i = @head i_1 = @head.next while i_1 != nil if(i.value > i_1.value) i.value, i_1.value = i_1.value, i.value cambio = true end i = i_1 i_1 = i_1.next end end end
to_s()
click to toggle source
# File lib/biblio/list.rb, line 104 def to_s actual = @head cadena = "|" while !actual.nil? cadena << actual.value.to_s if !actual.next.nil? cadena << ", " end actual = actual.next end cadena << "|" return cadena end