class Lista
Attributes
cola[RW]
head[RW]
nodo_actual[RW]
Public Class Methods
new(head,cola)
click to toggle source
# File lib/dieta/lista.rb, line 9 def initialize(head,cola) @head = head @cola = cola end
Public Instance Methods
each() { |value| ... }
click to toggle source
# File lib/dieta/lista.rb, line 51 def each while @head != @cola yield @head.value @head=@head.prev end if @head == @cola if @head == nil nil else yield @cola.value end end end
extract()
click to toggle source
eliminar el nodo y cambiar los valores al nodo anterior
# File lib/dieta/lista.rb, line 39 def extract() @cola=@cola.next end
extract_final()
click to toggle source
# File lib/dieta/lista.rb, line 43 def extract_final() @head = @head.prev end
insert(x)
click to toggle source
# File lib/dieta/lista.rb, line 14 def insert(x) node = Nodo.new(x,nil,nil) if @head==nil && @cola==nil node.prev = @cola node.next = @head @nodo_actual = node @head = node @cola = node else node.prev = @head node.next = nil @nodo_actual = node @head.next = node @head = node end end
insert_multiple(nodos)
click to toggle source
# File lib/dieta/lista.rb, line 32 def insert_multiple(nodos) nodos.each do |nd| insert(nd) end end
to_s()
click to toggle source
# File lib/dieta/lista.rb, line 47 def to_s @head.to_s end