Class: Lista
Instance Attribute Summary collapse
-
#finish ⇒ Object
readonly
Returns the value of attribute finish.
-
#list ⇒ Object
Returns the value of attribute list.
-
#ordenacion ⇒ Object
Returns the value of attribute ordenacion.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
Instance Method Summary collapse
- #each ⇒ Object
- #extraerfinish ⇒ Object
- #extraerstart ⇒ Object
-
#initialize ⇒ Lista
constructor
A new instance of Lista.
- #insertar(vall) ⇒ Object
- #insertarfinish(vall) ⇒ Object
- #insertarstart(vall) ⇒ Object
- #vacia ⇒ Object
Constructor Details
#initialize ⇒ Lista
Returns a new instance of Lista.
9 10 11 12 |
# File 'lib/nitz/libreria_lista.rb', line 9 def initialize() @start = nil @finish = nil end |
Instance Attribute Details
#finish ⇒ Object (readonly)
Returns the value of attribute finish.
5 6 7 |
# File 'lib/nitz/libreria_lista.rb', line 5 def finish @finish end |
#list ⇒ Object
Returns the value of attribute list.
6 7 8 |
# File 'lib/nitz/libreria_lista.rb', line 6 def list @list end |
#ordenacion ⇒ Object
Returns the value of attribute ordenacion.
6 7 8 |
# File 'lib/nitz/libreria_lista.rb', line 6 def ordenacion @ordenacion end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
5 6 7 |
# File 'lib/nitz/libreria_lista.rb', line 5 def start @start end |
Instance Method Details
#each ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/nitz/libreria_lista.rb', line 14 def each abcd = @start while abcd != nil do yield abcd.value abcd = abcd.next end end |
#extraerfinish ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/nitz/libreria_lista.rb', line 71 def extraerfinish if(vacia == true) return false else vall = @finish.value @finish = @finish.prev if(@finish == nil) @start = nil else @finish.next = nil end return vall end end |
#extraerstart ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/nitz/libreria_lista.rb', line 60 def extraerstart if (vacia == true) return false else vall = @start.value @start = @start.next return vall end end |
#insertar(vall) ⇒ Object
30 31 32 33 34 |
# File 'lib/nitz/libreria_lista.rb', line 30 def insertar(vall) aux = insertarfinish(vall) @ordenacion = self.sort aux end |
#insertarfinish(vall) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/nitz/libreria_lista.rb', line 47 def insertarfinish(vall) nd = Nodo.new(vall,nil,nil) if(vacia == true) @start = nd @finish = nd else nd.prev = @finish @finish.next = nd @finish = nd end return true end |
#insertarstart(vall) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/nitz/libreria_lista.rb', line 36 def insertarstart(vall) nd = Nodo.new(vall,nil,nil) if(vacia == true) @start = nd @finish = nd else @start.prev = nd end return true end |
#vacia ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/nitz/libreria_lista.rb', line 22 def vacia if (@start == nil) return true else return false end end |