static extern void _ResponseBody( [MarshalAs(UnmanagedType.IUnknown)] object transaction, [MarshalAs(UnmanagedType.LPArray)] byte[] data, int offset, int count, ContinuationDelegate continuation, [MarshalAs(UnmanagedType.Bool)] out bool async);
/// <summary> /// Performs a traversal on all descendants of a node in a depth first order, and yields /// on every node it visits. /// </summary> /// <param name="start">The node in the graph to start the travesal at.</param> /// <param name="continueCondition">The condition an edge has to met in order to be traversed.</param> /// <returns>A lazy loaded ordered collection containing all nodes it traversed.</returns> public static IEnumerable <Node> DepthFirstTraversal(this Node start, ContinuationDelegate continueCondition) { var stack = new Stack <Node>(); stack.Push(start); while (stack.Count > 0) { var current = stack.Pop(); yield return(current); foreach (var edge in current.OutgoingEdges) { if (continueCondition(current, edge)) { stack.Push(edge.GetOtherNode(current)); } } } }
/// <summary> /// Performs a traversl of all descendants of a node in a breadth first order, and yields /// on every node it visits. An edge is traversed when the given condition is met. /// </summary> /// <param name="start">The node in the graph to start the travesal at.</param> /// <param name="continueCondition">The condition an edge has to met in order to be traversed.</param> /// <returns></returns> public static IEnumerable <Node> BreadthFirstTraversal(this Node start, ContinuationDelegate continueCondition) { var queue = new Queue <Node>(); queue.Enqueue(start); while (queue.Count > 0) { var current = queue.Dequeue(); yield return(current); foreach (var edge in current.OutgoingEdges) { if (continueCondition(current, edge)) { queue.Enqueue(edge.GetOtherNode(current)); } } } }
void ICrosswalkModule.ResponseBody(object transaction, byte[] data, int offset, int count, ContinuationDelegate continuation, out bool async) { _ResponseBody(transaction, data, offset, count, continuation, out async); }