Sha256: 6ed08eabb958f0bdf06795368ad43c148f420eca6fffd3c24c94b34cade11514
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
Node = Struct.new(:value, :prev, :next) class Linked include Enumerable attr_accessor :head, :tail, :prev def initialize @head = @tail = nil @contador=0 end def add(value) node = Node.new(value) @head = node if @head.nil? if(@tail!=nil) @tail.next = node node.prev = @tail @contador=@contador+1 end @tail = node #@contador=@contador+1 end def to_s @aux=head aux2="" while @aux != nil do aux2 += "#{@aux.value.to_s}" @aux=@aux.next end "#{aux2}" end def ex_1er_elemento() if @head.nil? return false end @aux3=head @head = @head.next @aux3.next=nil end def empty? if @head.nil? return true else return false end end def extract_tail() aux="" if(@tail == nil) return false else aux = @tail.value @tail = @tail.prev return aux end end def each nodo = head while(nodo != nil) yield nodo.value[1][3] nodo = nodo.next end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
prct6-0.1.0 | lib/prct6/linked.rb |