class Algorithmable::DataStructs::Bag
Attributes
head[R]
size[R]
Public Class Methods
new()
click to toggle source
# File lib/algorithmable/data_structs/bag.rb, line 7 def initialize @head = nil @size = 0 end
Public Instance Methods
add(item)
click to toggle source
# File lib/algorithmable/data_structs/bag.rb, line 16 def add(item) old_head = @head @head = Node.new(item) @head.succ = old_head @size = @size.next end
each(&block)
click to toggle source
# File lib/algorithmable/data_structs/bag.rb, line 23 def each(&block) @head.each(&block) if @head end
empty?()
click to toggle source
# File lib/algorithmable/data_structs/bag.rb, line 12 def empty? @head.nil? end