Method: LemonGraph::NodeMap#initialize

Defined in:
ext/lemongraph/node_map.cc

#initialize(graph, default_value = nil) ⇒ NodeMap #initialize(graph) {|node, nodemap| ... } ⇒ NodeMap

Returns a new node map related to graph.

If no block is given, default_value will be returned when a value is fetched for a node for which no value was set.

If a block is given, it will be called if needed to provide values for nodes for which no value was set, instead of returning default_value.

Overloads:

  • #initialize(graph, default_value = nil) ⇒ NodeMap

    Parameters:

    • graph (Graph, Digraph)

      the graph this node map is to be bound to

    • default_value (Object) (defaults to: nil)

      the default value returned for nodes with no value.

  • #initialize(graph) {|node, nodemap| ... } ⇒ NodeMap

    Parameters:

    • graph (Graph, Digraph)

      the graph this node map is to be bound to

    Yield Parameters:

    Yield Returns:

    • (Object)

      the default value returned for this node



702
703
704
705
706
707
708
709
710
711
# File 'ext/lemongraph/node_map.cc', line 702

VALUE lemongraph_nodemap_initialize(int argc, VALUE *argv, VALUE self)
{
	VALUE rbg; 
	VALUE dflt = Qnil;
	VALUE proc = Qnil;
	rb_scan_args(argc, argv, "11&", &rbg, &dflt, &proc);
	LemonGraph::NodeMap& nm = lemongraph_nodemap_rb2ref(self);
	nm.initialize(self, rbg, dflt, proc);
	return self;
}