class Lista
Constants
- Node
- VERSION
Attributes
head[R]
tail[R]
Public Instance Methods
clasificar()
click to toggle source
# File lib/alu0100987522/lista.rb, line 68 def clasificar if(@head.value.sal >= 5) return true else return false end end
each() { |value| ... }
click to toggle source
# File lib/alu0100987522/lista.rb, line 86 def each x = @tail while(x != nil) yield x.value x = x.next end end
pop_head()
click to toggle source
# File lib/alu0100987522/lista.rb, line 34 def pop_head() if(@head == nil) return nil else aux = @head.value if(@head == @tail) @head = @head.prev @head, @tail = nil else @head = @head.prev @head.next = nil end return aux end end
pop_tail()
click to toggle source
# File lib/alu0100987522/lista.rb, line 51 def pop_tail() if(@tail == nil) return nil else aux = @tail.value if(@head == @tail) @tail = @tail.next @head, @tail = nil else @tail = @tail.next @tail.prev = nil end return aux end end
push_head(value)
click to toggle source
# File lib/alu0100987522/lista.rb, line 9 def push_head(value) if(@head == nil) @head = Node.new(value, nil, nil) @tail = head else nodo = Node.new(value, nil, @head) @head.next = nodo @head = nodo end end
push_tail(value)
click to toggle source
# File lib/alu0100987522/lista.rb, line 22 def push_tail(value) if(@tail == nil) @tail = Node.new(value, nil, nil) @head = tail else nodo = Node.new(value, @tail, nil) @tail.prev = nodo @tail = nodo end end
to_s()
click to toggle source
# File lib/alu0100987522/lista.rb, line 76 def to_s str = @tail.value.to_s() aux = @tail.next while(aux) str << aux.value.to_s() aux = aux.next end return str end