Method: Megam::CSARCollection#insert

Defined in:
lib/megam/core/csar_collection.rb

#insert(csar) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/megam/core/csar_collection.rb', line 54

def insert(csar)
  is_megam_csar(csar)
  if @insert_after_idx
    # in the middle of executing a run, so any nodes inserted now should
    # be placed after the most recent addition done by the currently executing
    # node
    @csars.insert(@insert_after_idx + 1, csar)
    # update name -> location mcsarings and register new node
    @csars_by_name.each_key do |key|
    @csars_by_name[key] += 1 if @csars_by_name[key] > @insert_after_idx
    end
    @csars_by_name[csar.link] = @insert_after_idx + 1
    @insert_after_idx += 1
  else
  @csars << csar
  @csars_by_name[csar.link] = @csars.length - 1
  end
end