class LinkedList
Attributes
head[RW]
Public Class Methods
new()
click to toggle source
# File lib/honey_mushroom/linked_list.rb, line 3 def initialize @head = nil end
Public Instance Methods
add(value)
click to toggle source
# File lib/honey_mushroom/linked_list.rb, line 7 def add(value) node = Node.new({value: value, next: nil}) node.next = @head @head = node end
find(value)
click to toggle source
# File lib/honey_mushroom/linked_list.rb, line 20 def find(value) current = @head until current.value == value current = current.next end return "Value: #{current.value} Next: #{current.next.value} ID: #{current.id}" end
remove_front()
click to toggle source
# File lib/honey_mushroom/linked_list.rb, line 13 def remove_front current = @head @head = current.next return current end