Class: Algorithmable::DataStructs::Bag::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/algorithmable/data_structs/bag.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item) ⇒ Node

Returns a new instance of Node.



30
31
32
33
# File 'lib/algorithmable/data_structs/bag.rb', line 30

def initialize(item)
  @item = item
  @succ = nil
end

Instance Attribute Details

#itemObject

Returns the value of attribute item.



28
29
30
# File 'lib/algorithmable/data_structs/bag.rb', line 28

def item
  @item
end

#succObject

Returns the value of attribute succ.



28
29
30
# File 'lib/algorithmable/data_structs/bag.rb', line 28

def succ
  @succ
end

Instance Method Details

#each {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



35
36
37
38
# File 'lib/algorithmable/data_structs/bag.rb', line 35

def each(&block)
  yield self
  @succ.each(&block) if @succ
end