Method: DLLModule::DLL#extract_tail

Defined in:
lib/food/dll.rb

#extract_tailNode

Extract element in DLL tail

Returns:

  • value of the node that was in the tail



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/food/dll.rb', line 71

def extract_tail
  if @tail.nil?
    return nil
  else
    @size -= 1
    
    node_to_return = @tail
    
    @tail = @tail.prev
    @tail.next = nil
    
    node_to_return.prev = nil
    return node_to_return.value
  end
end