Class: Lista

Inherits:
Object
  • Object
show all
Defined in:
lib/menud/lista.rb

Instance Method Summary collapse

Constructor Details

#initializeLista

We set to nil value the initial node



28
29
30
31
# File 'lib/menud/lista.rb', line 28

def initialize ()
       
    @elemento = Nodo.new(nil)
end

Instance Method Details

#elementoObject

Just to define the element



34
35
36
37
# File 'lib/menud/lista.rb', line 34

def elemento
    
    @elemento
end

#extraer_elementoObject

We extract a element from the simple linked list



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

def extraer_elemento 
    
    aux = @elemento
    @elemento = @elemento.next
    aux.value
end

#insertar_elemento(nodo) ⇒ Object

We insert a new element on the simple linked list



40
41
42
43
44
45
46
47
# File 'lib/menud/lista.rb', line 40

def insertar_elemento(nodo)
    
    if @elemento != nil
        
        nodo.next = @elemento
        @elemento = nodo
    end
end