Class: Lista

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/nitz/libreria_lista.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLista

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

#finishObject (readonly)

Returns the value of attribute finish.



5
6
7
# File 'lib/nitz/libreria_lista.rb', line 5

def finish
  @finish
end

#listObject

Returns the value of attribute list.



6
7
8
# File 'lib/nitz/libreria_lista.rb', line 6

def list
  @list
end

#ordenacionObject

Returns the value of attribute ordenacion.



6
7
8
# File 'lib/nitz/libreria_lista.rb', line 6

def ordenacion
  @ordenacion
end

#startObject (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

#eachObject



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

#extraerfinishObject



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

#extraerstartObject



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

#vaciaObject



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