Class: Lista
Instance Attribute Summary collapse
-
#head ⇒ Object
Returns the value of attribute head.
-
#next_node ⇒ Object
Returns the value of attribute next_node.
-
#prev_node ⇒ Object
Returns the value of attribute prev_node.
-
#tail ⇒ Object
Returns the value of attribute tail.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #add_final(nodo) ⇒ Object
- #add_muchos(nodo) ⇒ Object
- #add_principio(nodo) ⇒ Object
- #borrar_final ⇒ Object
- #borrar_principio ⇒ Object
- #each ⇒ Object
-
#initialize ⇒ Lista
constructor
A new instance of Lista.
Constructor Details
Instance Attribute Details
#head ⇒ Object
Returns the value of attribute head.
9 10 11 |
# File 'lib/referencia/lista.rb', line 9 def head @head end |
#next_node ⇒ Object
Returns the value of attribute next_node.
9 10 11 |
# File 'lib/referencia/lista.rb', line 9 def next_node @next_node end |
#prev_node ⇒ Object
Returns the value of attribute prev_node.
9 10 11 |
# File 'lib/referencia/lista.rb', line 9 def prev_node @prev_node end |
#tail ⇒ Object
Returns the value of attribute tail.
9 10 11 |
# File 'lib/referencia/lista.rb', line 9 def tail @tail end |
#value ⇒ Object
Returns the value of attribute value.
9 10 11 |
# File 'lib/referencia/lista.rb', line 9 def value @value end |
Instance Method Details
#add_final(nodo) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/referencia/lista.rb', line 40 def add_final(nodo) aux = Nodo.new(nodo, nil, nil) aux.prev_node = @tail @tail.next_node = aux @tail = aux end |
#add_muchos(nodo) ⇒ Object
55 56 57 58 59 |
# File 'lib/referencia/lista.rb', line 55 def add_muchos(nodo) nodo.each do |num| self.add_principio(num) end end |
#add_principio(nodo) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/referencia/lista.rb', line 18 def add_principio(nodo) aux = Nodo.new(nodo, nil, nil) if (@head == nil && @tail == nil) @head = aux @tail = aux else aux.next_node = @head @head.prev_node = aux @head = aux end end |
#borrar_final ⇒ Object
35 36 37 38 |
# File 'lib/referencia/lista.rb', line 35 def borrar_final @tail = @tail.prev_node @tail.next_node = nil end |
#borrar_principio ⇒ Object
30 31 32 33 |
# File 'lib/referencia/lista.rb', line 30 def borrar_principio @head = @head.next_node @head.prev_node = nil end |
#each ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/referencia/lista.rb', line 47 def each i = @head while (i != nil) yield i.value i = i.next_node end end |