Method: LemonGraph::NodeMap#initialize_copy

Defined in:
ext/lemongraph/node_map.cc

#initialize_copy(orig) ⇒ self

Method called by dup and clone methods.

Returns:

  • (self)


718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
# File 'ext/lemongraph/node_map.cc', line 718

VALUE lemongraph_nodemap_initialize_copy(VALUE self, VALUE orig)
{
  rb_call_super(1, &orig);
  LemonGraph::NodeMap& from = lemongraph_nodemap_rb2ref(orig);
  LemonGraph::NodeMap& to   = lemongraph_nodemap_rb2ref(self);
  to.initialize(self, from.graph(), from.default_value(), from.default_proc());
  if (from.is_for_directed_graph()) {
    for (lemon::ListDigraph::NodeIt n(lemongraph_digraph_rb2ref(from.graph())); n != lemon::INVALID; ++n) {
      const LemonGraph::RBValue& v = from[n];
      if (v.is_valid())
        to[n] = v;
    }
  }
  else {
    for (lemon::ListGraph::NodeIt n(lemongraph_graph_rb2ref(from.graph())); n != lemon::INVALID; ++n) {
      const LemonGraph::RBValue& v = from[n];
      if (v.is_valid())
        to[n] = v;
    }
  }
  return self;
}