Class: LList
Instance Attribute Summary collapse
-
#head ⇒ Object
Returns the value of attribute head.
-
#tail ⇒ Object
Returns the value of attribute tail.
Instance Method Summary collapse
- #actual ⇒ Object
- #each ⇒ Object
-
#initialize(perry) ⇒ LList
constructor
A new instance of LList.
-
#popb ⇒ Object
saca por el principio.
-
#pope ⇒ Object
saca por el final.
-
#pushb(value) ⇒ Object
Introduce al inicio.
-
#pushe(value) ⇒ Object
Introduce al final.
- #shownext ⇒ Object
Constructor Details
#initialize(perry) ⇒ LList
Returns a new instance of LList.
8 9 10 11 12 |
# File 'lib/Dieta/LList.rb', line 8 def initialize(perry) a=Node.new(perry,nil,nil) @head=a @tail=a end |
Instance Attribute Details
#head ⇒ Object
Returns the value of attribute head.
5 6 7 |
# File 'lib/Dieta/LList.rb', line 5 def head @head end |
#tail ⇒ Object
Returns the value of attribute tail.
5 6 7 |
# File 'lib/Dieta/LList.rb', line 5 def tail @tail end |
Instance Method Details
#actual ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/Dieta/LList.rb', line 73 def actual if @head==nil return nil else return @head.value end end |
#each ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/Dieta/LList.rb', line 82 def each() a=@head while a!=nil yield a.value a=a.next end end |
#popb ⇒ Object
saca por el principio
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/Dieta/LList.rb', line 39 def popb() if @head==nil @head=nil @tail=nil return nil else a=@head @head=@head.next return a.value end end |
#pope ⇒ Object
saca por el final
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/Dieta/LList.rb', line 52 def pope if @tail==nil @head=nil @tail=nil return nil else a=@tail @tail=@tail.back return a.value end end |
#pushb(value) ⇒ Object
Introduce al inicio
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/Dieta/LList.rb', line 14 def pushb(value) if @head==nil a=Node.new(value,nil,nil) @head=a @tail=@head else a=Node.new(value,@head,nil) @head.back=a @head=a end end |
#pushe(value) ⇒ Object
Introduce al final
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/Dieta/LList.rb', line 27 def pushe(value) if @tail==nil a=Node.new(value,nil,nil) @head=a @tail=@head else a=Node.new(value,nil,@tail) @tail.next=a @tail=a end end |
#shownext ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/Dieta/LList.rb', line 65 def shownext if @head.next==nil return nil else return @head.next.value end end |