c# - call graph IEnumerator -


I have to implement a call graph such as Id = Id (absolute); And there was not a problem

Now I have to implement a calculator which lists one at a time, which is all topological ordering between calls which satisfy the dependency order .

And here's the problem.

This is a simple node for the call graph: CallGraphNode {Private string name; Public listing & lt; CallGraphNode & gt; Dependents = new list & lt; CallGraphNode & gt; (); Public perfection reliance; Executed Private Bull = Wrong; Public Bull Executionable {Return Dependency == 0; }} Public Bull was executed ({executed return;} set {executed = value;}} public CallGraphNode (name of string) {this.name = name; dependency = 0;} public override string toasting (return) Name;} Public Zero AddDependent (CallGraphNode N) {dependants.Add (n);}}

And this call graph is the same class:

  class Call Graph: INIMERABLE & lt; list & lt; call graphnode & gt; & gt; {public list & lt; call graphnode & gt; nodes = new list & lt; callGraphNode & gt; ( ); Public Zero AddNode (CallGraphNode n) {Add Node;} Public Static Zero Show (IEnumerable & lt; CallGraphNode & gt; n) {foreach (ng in callGraphNode node) {Console.Write ("{0} ", Node);} console. Wrightite ();} Fixed IEnumerable & lt; list & gt; callGraphNode & gt; & gt; enfymerfunctions (list & amp; lt; call graphnode & gt; executable, list & amp; lift; CallGraphNode & gt; res) {If (executable.ccount == 0) yield returns ridge; Second Forex (CallGraphNode n in executable) {If (! N.Executed) res.Add (n); & Lt; CallGraphNode & gt; Next_executable = New list & lt; CallGraphNode & gt; (Executable); Executable.Remove (N); Foreach (call.graphNode M in independent.g) if (--m.dependencies == 0) next_executable.Add (m); Foreign exchange (list & amp; lt; CallGraphNode & gt; in other enfimated functions (Next_Great, Ridge) yield returns; Foreach (CallGraphNode M in n.dependents) m. Dependencies ++; If (! N.Executed) res.Remove (n); }} IEnumerator & lt; List & lt; CallGraphNode & gt; & Gt; IEnumerable & lt; List & lt; CallGraphNode & gt; & Gt; .GetEnumerator () {List & lt; CallGraphNode & gt; Executable = New list & lt; CallGraphNode & gt; (); Forward (call graph node in nodes) if (n.Executable || n.Executed) is executable. Add (n); & Lt; CallGraphNode & gt; Output = new list & lt; CallGraphNode & gt; (); Novel (list & lt; CallGraphNode & gt; list) yield list in advance (encuitable, output); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator () {Throw New NotImplementedException); }}   

Now, the problem is that it will not work. When I try to create a IEnumerator and assign it a GetEnumerator () return value, I get a casting error and try to do it honestly What time did I expect:

  IEnumerator & lt; List & lt; CallGraphNode & gt; & Gt; Lt = cg.GetEnumerator ();   

Then I have tried:

  system Selection. GenericList & lt; CallGraphNode & gt; Enumerator en = cg.nodes.GetEnumerator ();   

This works, but the method anamoretifon is never called and the calculator has the basic list of graph nodes only.

Any thoughts?

The problem is that you both IEnumerable <

  IEnumerator & lt; List & lt; CallGraphNode & gt; & Gt; T & gt;  IEnumerable & lt; List & lt; CallGraphNode & gt; & Gt; .GetEnumerator ()   

To apply a "normal" interface:

  Public IEnumerator & lt; List & lt; CallGraphNode & gt; & Gt; ; GetEnumerator ()   

Alternatively, you can stick with clear interface implementation, but use it:

  IEnumerable & lt; List & lt; CallGraphNode & gt; & Gt; Sequence = CG; IEnumerator & LT; From the list & lt; CallGraphNode & gt; & Gt; Lieutenant = sequence GETEnumerator ();    

Comments