class Lista

Clase que representa una lista enlazada

Attributes

beginning[R]
end[R]

Public Class Methods

new() click to toggle source

Constructor de la clase lista

# File lib/menus/lista.rb, line 17
def initialize()
    @beginning = nil;
    @end = nil;
end

Public Instance Methods

each() { |value| ... } click to toggle source
# File lib/menus/lista.rb, line 8
def each()
    actual = @beginning
    while actual != nil
        yield actual.value
        actual = actual.p_next
    end
end
pop_front() click to toggle source

Extraer al inicio

# File lib/menus/lista.rb, line 38
def pop_front()
    aux = @beginning;
    @beginning = @beginning.p_next;
    @beginning.p_prev = nil
    return aux.value;
end
push_front(value) click to toggle source

Insertar al inicio

# File lib/menus/lista.rb, line 23
def push_front(value);
    aux = Node.new(value, @beginning, @nil);
    @end = @beginning;
    @beginning = aux;
end
push_set(set) click to toggle source

Insertar al inicio un set de elementos

# File lib/menus/lista.rb, line 31
def push_set(set)
    set.each do |i|
        push_front(i)
    end
end
to_s() click to toggle source
# File lib/menus/lista.rb, line 45
def to_s()
    aux = @beginning;
    str = "";
    while (aux != nil)
        str << "#{aux.value}\n\n"
        aux = aux.p_next;
    end
    return str;
end