Class: Lista

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/examen/lista.rb

Direct Known Subclasses

Examen::Examen

Defined Under Namespace

Classes: Nodo

Instance Method Summary collapse

Constructor Details

#initialize(nodo) ⇒ Lista

Returns a new instance of Lista.



18
19
20
21
22
# File 'lib/examen/lista.rb', line 18

def initialize(nodo)
    @inicio=Nodo.new(nil)
    @fin=Nodo.new(nil)
    @fin=@inicio
end

Instance Method Details

#each(&block) ⇒ Object



81
82
83
84
85
86
87
88
# File 'lib/examen/lista.rb', line 81

def each(&block)
     tempo = @inicio
     while tempo != nil
        block.call(tempo)
         #yield tempo.value
         tempo=tempo.next
     end
end

#extObject



52
53
54
55
56
# File 'lib/examen/lista.rb', line 52

def ext 
    aux=@inicio
    @inicio=@inicio.next
    aux.value
end

#extfinObject



58
59
60
61
62
# File 'lib/examen/lista.rb', line 58

def extfin
    aux=@fin
    @fin=@fin.prev
    aux.value
end

#finObject



70
71
72
73
# File 'lib/examen/lista.rb', line 70

def fin
    
    @fin
end

#inicioObject



65
66
67
68
# File 'lib/examen/lista.rb', line 65

def inicio
    
    @inicio
end

#pop(nodo) ⇒ Object



47
48
49
50
# File 'lib/examen/lista.rb', line 47

def pop(nodo)
    @inicio=@inicio.next
   #@inicio.prev=nil
end

#push(nodo) ⇒ Object

poner if preguntar Nodo vacio



25
26
27
28
29
30
31
# File 'lib/examen/lista.rb', line 25

def push(nodo)    #poner if preguntar Nodo vacio
    
    nodo.next =@inicio
    @inicio.prev=nodo
    @inicio=nodo

end

#pushf(nodo) ⇒ Object

poner if preguntar Nodo vacio



36
37
38
39
40
41
42
43
# File 'lib/examen/lista.rb', line 36

def pushf(nodo)    #poner if preguntar Nodo vacio
   
    @inicio=nodo
    @fin=nodo
    
 
   
end

#respuestaObject



76
77
78
# File 'lib/examen/lista.rb', line 76

def respuesta
    @respuesta
end