Sha256: 03d7c02debe8716c05e46bea811a93496067722ce9ebf5c36658846363ffbd6c
Contents?: true
Size: 866 Bytes
Versions: 1
Compression:
Stored size: 866 Bytes
Contents
Node = Struct.new(:value, :next, :prev) class Lista include Enumerable attr_reader :cabeza,:cola def initialize() @cabeza,@cola = nil end def each aux = @cabeza while aux != @cola do yield aux.value aux = aux.next end yield aux.value end def push(other) if @cabeza == nil @cabeza = other other.next = @cabeza other.prev = @cabeza @cola = other end if @cabeza != nil other.next = @cabeza other.prev = @cola @cola.next = other @cabeza.prev = other @cola = other end end def pop_first() @cabeza = @cabeza.next end def pop_last() @cola = @cola.prev end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
alimento_0100763478-0.1.0 | lib/alimento/lista.rb |