class LinkedList

Attributes

head[RW]
tail[RW]

Public Class Methods

new() click to toggle source
# File lib/practica7/practica7.rb, line 7
def initialize
        @head = @tail = nil
end

Public Instance Methods

add(value) click to toggle source
# File lib/practica7/practica7.rb, line 10
def add(value)
         node = Node.new(value)
         @head = node if @head.nil?
         @tail.next = node unless @tail.nil?
                      node.prev = @tail unless @tail.nil?
         @tail = node
 end
pop() click to toggle source
# File lib/practica7/practica7.rb, line 17
def pop
       aux=@head
       @head=@head.next
       aux
end
size() click to toggle source
# File lib/practica7/practica7.rb, line 22
def size
       tam =0
       aux=@head
       while aux!=nil do
               tam = tam + 1
               aux=aux.next
       end
       tam
end