private void AddLeave(RouteBuilderNode node) { if (node == null || node.Matrix.State == RouteMatrixState.Unreachable) { return; } if (Leaves.First == null) { Leaves.AddFirst(node); } else { var compareFirst = node.CompareTo(Leaves.First.Value); if (compareFirst <= 0) { Leaves.AddFirst(node); } else { var compareLast = node.CompareTo(Leaves.Last.Value); if (compareLast > 0) { Leaves.AddLast(node); } else { var n = Leaves.First.Next; while (node.CompareTo(n.Value) > 0) { n = n.Next; } Leaves.AddBefore(n, node); } } } }
public RouteBuilder(IEnumerable <IRoute> routes) { var _rootNode = new RouteBuilderNode(new RouteMatrix(routes)); Leaves.AddFirst(_rootNode); }