Class: Lista
Instance Attribute Summary collapse
-
#head ⇒ Object
Returns the value of attribute head.
-
#tail ⇒ Object
Returns the value of attribute tail.
Instance Method Summary collapse
-
#each ⇒ Object
Each.
-
#empty ⇒ Object
Empty.
-
#extract_head ⇒ Object
Head.
-
#extract_tail ⇒ Object
Tail.
-
#initialize(valor) ⇒ Lista
constructor
Constructor initialize.
-
#insert_head(valor) ⇒ Object
Head.
-
#insert_tail(valor) ⇒ Object
Tail.
Constructor Details
Instance Attribute Details
#head ⇒ Object
Returns the value of attribute head.
4 5 6 |
# File 'lib/Dieta/lista.rb', line 4 def head @head end |
#tail ⇒ Object
Returns the value of attribute tail.
4 5 6 |
# File 'lib/Dieta/lista.rb', line 4 def tail @tail end |
Instance Method Details
#each ⇒ Object
Each
14 15 16 17 18 19 20 |
# File 'lib/Dieta/lista.rb', line 14 def each aux = @head while aux != nil yield aux.value aux = aux.next end end |
#empty ⇒ Object
Empty
23 24 25 |
# File 'lib/Dieta/lista.rb', line 23 def empty @head.value==nil end |
#extract_head ⇒ Object
Head
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/Dieta/lista.rb', line 59 def extract_head if empty nil else aux = @head.value @head = @head.next @head.prev = nil aux end end |
#extract_tail ⇒ Object
Tail
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/Dieta/lista.rb', line 72 def extract_tail if empty nil else aux = @tail.value @tail = @tail.prev @tail.next = nil aux end end |