示例#1
0
        private void Add(RouteBuilderNode node)
        {
            if (node == null)
            {
                return;
            }
            switch (node.Matrix.State)
            {
            case RouteMatrixState.IsComplete:
                Completed  = node.Matrix;
                IsComplete = true;
                break;

            case RouteMatrixState.Process:
                AddLeave(node);
                break;
            }
        }
示例#2
0
        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);
                    }
                }
            }
        }
示例#3
0
        public RouteBuilder(IEnumerable <IRoute> routes)
        {
            var _rootNode = new RouteBuilderNode(new RouteMatrix(routes));

            Leaves.AddFirst(_rootNode);
        }