public static GetChildDelegate FindTreeGetChildMethod() { GetChildDelegate result = null; MethodInfo[] methodInfos = typeof(TreeT).GetMethods(BindingFlags.Public | BindingFlags.Static); for (int i = 0; i < methodInfos.Length; ++i) { if (methodInfos[i].Name == "TreeGetChild") { result = (GetChildDelegate)Delegate.CreateDelegate(typeof(GetChildDelegate), methodInfos[i]); break; } } return(result); }
/// <summary> /// Init iterative depth-first search. /// </summary> /// <param name="context">Custom data to be passed to delegates.</param> /// <param name="getChild">Delegate to obtain a child with given index for current branch.</param> /// <param name="processResult">Delegate to process result.</param> /// <param name="maxDepth">Depth limit (negative is treated as no limit).</param> public void Init(object context, GetChildDelegate <T> getChild, ProcessResultDelegate <T> processResult, int maxDepth = -1) { if (getChild == null) { throw new ArgumentNullException("getChild"); } if (processResult == null) { throw new ArgumentNullException("processResult"); } this.context = context; this.getChild = getChild; this.processResult = processResult; this.maxDepth = maxDepth; branch = new List <T>(); indices = new List <int>(); }
internal static void RegisterGetChild(GetChildDelegate cb) { getChild = cb; }
/// <summary> /// Init enumerable depth-first search. /// </summary> /// <param name="context">Custom data to be passed to delegates.</param> /// <param name="getChild">Delegate to obtain a child with given index for current branch.</param> /// <param name="maxDepth">Depth limit (negative is treated as no limit).</param> public void Init(object context, GetChildDelegate <T> getChild, int maxDepth = -1) { dfs.Init(context, getChild, (ctx, branch) => {}, maxDepth); }