class List
Attributes
head[RW]
tail[RW]
Public Class Methods
new()
click to toggle source
# File lib/biblio/lista.rb, line 9 def initialize() @head = nil @tail = nil end
Public Instance Methods
each() { |nil| ... }
click to toggle source
# File lib/biblio/lista.rb, line 94 def each if (@head == nil) and (@tail == nil) yield nil elsif (@head == @tail) yield @head.value else while (@head != nil) yield @head.value @head = @head.next end end end
empty?()
click to toggle source
# File lib/biblio/lista.rb, line 15 def empty? if @head == nil return true else return false end end
extract_beginning()
click to toggle source
# File lib/biblio/lista.rb, line 68 def extract_beginning() if @head == nil return nil else temporal_node = @head @head = @head.next return temporal_node end end
extract_end()
click to toggle source
# File lib/biblio/lista.rb, line 79 def extract_end() if @tail == nil return nil else temporal_node = @tail @tail = @tail.prev return temporal_node end end
insert_beginning(x)
click to toggle source
# File lib/biblio/lista.rb, line 24 def insert_beginning(x) node = Node.new(x,nil,nil) if (@head == nil) @head = node @tail = node else temporal_node = @head @head = node @head.next = temporal_node temporal_node.prev = @head end end
insert_end(x)
click to toggle source
# File lib/biblio/lista.rb, line 43 def insert_end(x) node = Node.new(x,nil,nil) if (@head == nil) @head = node @tail = node else temporal_node = @tail @tail = node @tail.prev = temporal_node temporal_node.next = @tail end end
insert_multi(nodes)
click to toggle source
# File lib/biblio/lista.rb, line 61 def insert_multi(nodes) nodes.each do |nodo| insert_beginning(nodo) end end