Пример #1
0
        static long GetDirectoriesSize(
            String strCurDir,
            System.Collections.Generic.LinkedList <DirInfo> parentList)
        {
            String[] strFiles = Directory.GetFiles(strCurDir, "*.*");
            long     aSize    = 0;

            foreach (String s in strFiles)
            {
                FileInfo info = new FileInfo(s);
                aSize += info.Length;
            }


            DirInfo infoCur = new DirInfo();

            infoCur.dirName = strCurDir;
            infoCur.curSize = aSize;
            System.Collections.Generic.LinkedListNode <DirInfo> infoMine = parentList.AddLast(infoCur);


            String[] strDirectories = Directory.GetDirectories(strCurDir);
            foreach (String sDirs in strDirectories)
            {
                aSize += GetDirectoriesSize(sDirs, infoMine.Value.listChild);
            }

            //Console.WriteLine("{0} size({1,0:N0}) Bytes", strCurDir, aSize);
            //infoMine.Value.aSize = aSize;
            infoMine.Value.aSize = aSize;

            return(aSize);
        }
Пример #2
0
 private void FindNeighbours_List_Recursion(int index, int level, CounterClass myClass)
 {
     try
     {
         if (level == 0)
         {
             return;
         }
         System.Collections.Generic.LinkedListNode <int> counter = AdjacencyList[index].First;
         while (counter != null)
         {
             myClass.neighbours[myClass.counter] = counter.Value;
             myClass.counter++;
             FindNeighbours_List_Recursion(counter.Value, level - 1, myClass);
             counter = counter.Next;
         }
     }
     catch (NullReferenceException nre)
     {
         System.Console.WriteLine(nre.StackTrace);
         System.Console.WriteLine(nre.Message);
     }
     catch (IndexOutOfRangeException ior)
     {
         System.Console.WriteLine(ior.StackTrace);
         System.Console.WriteLine(ior.Message);
     }
 }
    /// <summary>
    /// Converts the given end node and path node information
    /// to a path from the start node to the end node
    /// </summary>
    /// <param name="path">path to convert</param>
    /// <returns>string for path</returns>
    private string ConvertPathToString(GraphNode <int> endNode, Dictionary <GraphNode <int>, PathNodeInfo <int> > pathNodes)
    {
        //Build linked list for path in correct order
        System.Collections.Generic.LinkedList <GraphNode <int> > path =
            new System.Collections.Generic.LinkedList <GraphNode <int> >();

        path.AddFirst(endNode);
        GraphNode <int> previous = pathNodes[endNode].Previous;

        while (previous != null)
        {
            path.AddFirst(previous);
            previous = pathNodes[previous].Previous;
        }

        //Build and return string
        StringBuilder pathString = new StringBuilder();

        System.Collections.Generic.LinkedListNode <GraphNode <int> > currentNode = path.First;
        int nodeCount = 0;

        while (currentNode != null)
        {
            nodeCount++;
            pathString.Append(currentNode.Value.Value);
            if (nodeCount < path.Count)
            {
                pathString.Append(" ");
            }

            currentNode = currentNode.Next;
        }

        return(pathString.ToString());
    }
Пример #4
0
        /// <summary>
        /// Adds a new node containing the specified value at the end of this <see cref="ArrayBuilder{T}"/>.
        /// </summary>
        /// <param name="value">The value to add at the end of this <see cref="ArrayBuilder{T}"/>.</param>
        /// <returns>The new <see cref="System.Collections.Generic.LinkedListNode{T}"/> containing value.</returns>
        public System.Collections.Generic.LinkedListNode <T> AddLast(T value)
        {
            System.Collections.Generic.LinkedListNode <T> result = InnerList.AddLast(value);

            OnUpdate();

            return(result);
        }
Пример #5
0
        /// <summary>
        /// Adds a new node containing the specified value before the specified existing node in this <see cref="ArrayBuilder{T}"/>.
        /// </summary>
        /// <param name="node">The <see cref="System.Collections.Generic.LinkedListNode{T}"/> before which to insert a new <see cref="System.Collections.Generic.LinkedListNode{T}"/> containing value.</param>
        /// <param name="value">The value to add to this <see cref="ArrayBuilder{T}"/>.</param>
        /// <returns>The new <see cref="System.Collections.Generic.LinkedListNode{T}"/> containing value.</returns>
        /// <exception cref="ArgumentNullException">node is null.</exception>
        /// <exception cref="InvalidOperationException">node is not in the current <see cref="ArrayBuilder{T}"/>.</exception>
        public System.Collections.Generic.LinkedListNode <T> AddBefore(System.Collections.Generic.LinkedListNode <T> node, T value)
        {
            System.Collections.Generic.LinkedListNode <T> result = InnerList.AddBefore(node, value);

            OnUpdate();

            return(result);
        }
Пример #6
0
        private void ReductionEvent(ReduceEventArgs pValue)
        {
            switch (pValue.Token.Symbol.ToString())
            {
                case "<Value>":
                    string Value = "";//pValue.Token.Tokens[0].ToString().Trim(new char[] { '{', '}' });
                    //System.Console.Write(Value);
                    this.NodeStack.Push(new TreeNode(Value));
                    break;
                case "<Negate Exp>":
                    System.Collections.Generic.LinkedListNode<string> Node = new System.Collections.Generic.LinkedListNode<string>("-");
                    //System.Console.Write("-");
                    TreeNode NegateNode = new TreeNode("-");
                    NegateNode.Right = this.NodeStack.Pop();
                    this.NodeStack.Push(NegateNode);
                    break;
                case "<Add Exp>":
                    //System.Console.Write("+");
                    TreeNode AddExpNode = new TreeNode("+");
                    AddExpNode.Right = this.NodeStack.Pop();
                    AddExpNode.Left = this.NodeStack.Pop();
                    this.NodeStack.Push(AddExpNode);
                    break;
                case "<Assign_Statement>":
                    string Identifier = "";//args.Token.Tokens[0].ToString().Trim(new char[] { '[', ']' });
                    //System.Console.Write(Identifier);
                    //System.Console.Write("=");
                    TreeNode AssignNode = new TreeNode("=");
                    this.TreeList.GetLast().Right = AssignNode;
                    AssignNode.Right = this.NodeStack.Pop();
                    AssignNode.Left = new TreeNode(Identifier);
                    this.NodeStack.Push(AssignNode);
                    break;
                case "<Statement>":
                    TreeNode Statement = new TreeNode("statement\n");
                    Statement.Right = this.NodeStack.Pop();
                    Statement.Left = this.NodeStack.Pop();
                    this.NodeStack.Push(Statement);
                    break;

                case "<StatementList>":
                    TreeNode StatementList = new TreeNode("sl\n");
                    StatementList.Right = this.NodeStack.Pop();
                    StatementList.Left = this.NodeStack.Pop();
                    this.NodeStack.Push(StatementList);
                    break;
                case "<Program>":
                    TreeNode Program = new TreeNode("program");
                    Program.Right = this.NodeStack.Pop();
                    Program.Left = this.NodeStack.Pop();
                    this.NodeStack.Push(Program);
                    break;
                default:
                    System.Console.WriteLine(pValue.Token.Symbol.ToString());
                    break;
            }
        }
Пример #7
0
        public override void EmitAsk(Ask ask)
        {
            // Emit ask to BuySide strategy.
            base.EmitAsk(ask);

            System.Collections.Generic.LinkedListNode <OrderProcessor> processorNode = processors.First;

            // Send ask to order processors.
            while (processorNode != null)
            {
                OrderProcessor processor = processorNode.Value;
                processor.OnAsk(ask);
                processorNode = processorNode.Next;
            }
        }
Пример #8
0
        public override void EmitBid(Bid bid)
        {
            // Emit bid to BuySide strategy.
            base.EmitBid(bid);

            System.Collections.Generic.LinkedListNode <OrderProcessor> processorNode = processors.First;

            // Send bid to order processors.
            while (processorNode != null)
            {
                OrderProcessor processor = processorNode.Value;
                processor.OnBid(bid);
                processorNode = processorNode.Next;
            }
        }
Пример #9
0
        public override void EmitTrade(Trade trade)
        {
            // Emit trade to BuySide strategy.
            base.EmitTrade(trade);

            System.Collections.Generic.LinkedListNode <OrderProcessor> processorNode = processors.First;

            // Send trade to order processors.
            while (processorNode != null)
            {
                OrderProcessor processor = processorNode.Value;
                processor.OnTrade(trade);
                processorNode = processorNode.Next;
            }
        }
Пример #10
0
        protected override void OnExecutionReport(ExecutionReport report)
        {
            System.Collections.Generic.LinkedListNode <OrderProcessor> processorNode = processors.First;
            while (processorNode != null)
            {
                OrderProcessor processor = processorNode.Value;
                processor.OnExecutionReport(report);

                if (processor.IsDone)
                {
                    processors.Remove(processor);
                }

                processorNode = processorNode.Next;
            }
        }
Пример #11
0
        /// <summary>
        /// Adds the specified new node at the end of this <see cref="ArrayBuilder{T}"/>.
        /// </summary>
        /// <param name="node">The new <see cref="System.Collections.Generic.LinkedListNode{T}"/> to add at the end of this <see cref="ArrayBuilder{T}"/>.</param>
        /// <exception cref="ArgumentNullException">node is null.</exception>
        /// <exception cref="InvalidOperationException">node belongs to another <see cref="ArrayBuilder{T}"/>.</exception>
        public void AddLast(System.Collections.Generic.LinkedListNode <T> node)
        {
            InnerList.AddLast(node);

            OnUpdate();
        }
Пример #12
0
        /// <summary>
        /// Adds the specified new node before the specified existing node in this <see cref="ArrayBuilder{T}"/>.
        /// </summary>
        /// <param name="node">The <see cref="System.Collections.Generic.LinkedListNode{T}"/> before which to insert newNode.</param>
        /// <param name="newNode">The new <see cref="System.Collections.Generic.LinkedListNode{T}"/> to add to this <see cref="ArrayBuilder{T}"/>.</param>
        /// <exception cref="ArgumentNullException">node is null. -or- newNode is null.</exception>
        /// <exception cref="InvalidOperationException">node is not in the current <see cref="ArrayBuilder{T}"/>. -or- newNode belongs to another <see cref="ILinkedList{T}"/>.</exception>
        public void AddBefore(System.Collections.Generic.LinkedListNode <T> node, System.Collections.Generic.LinkedListNode <T> newNode)
        {
            InnerList.AddBefore(node, newNode);

            OnUpdate();
        }
Пример #13
0
        public bool MoveNext()
        {
            // Debug.WriteLine("calling PropertyNameEnumerator.MoveNext");
            while (_dobject != null)
            {
                var array = _dobject as mdr.DArray;
                if (array != null)
                {
                    while (++_elementsIndex < array.ElementsLength)
                    {
                        if (!_visiteds.Contains(-_elementsIndex))
                        {
                            _visiteds.Add(-_elementsIndex);
                            _current = _elementsIndex.ToString();
                            return(true);
                        }
                    }
                }

                /*
                 * ///Spec says the order of retreiving the properties does not matter, so the following code is faster
                 * ///However some stupid websites (e.g. BBC) count on the fact that Browsers list properties with a certain order
                 * ///So, we had to change to the slower to be browser compatible, rather than spec compatible
                 * if (_map == null)
                 *  _map = _dobject.Map;
                 *
                 * while (_map != null)
                 * {
                 *  var prop = _map.Property;
                 *  _map = _map.Parent;
                 *
                 *  if (!prop.IsNotEnumerable && !_visiteds.Contains(prop.NameId))
                 *  {
                 *      _visiteds.Add(prop.NameId);
                 *      _current = prop.Name;
                 *      return true;
                 *  }
                 * }
                 * _dobject = _dobject.Prototype;
                 * _elementsIndex = -1;
                 * _current = null;
                 */
                if (_currentNode == null)
                {
                    //We may have reached to the end of collected properties, but meanwhile some new ones may have been added
                    _propNames.Clear();
                    if (_map != null && _map != _dobject.Map)
                    {
                        _map = _dobject.Map;
                    }
                    for (var m = _dobject.Map; m != _map; m = m.Parent)
                    {
                        var prop = m.Property;
                        if (!prop.IsNotEnumerable && !_visiteds.Contains(prop.NameId))
                        {
                            _visiteds.Add(prop.NameId);
                            _propNames.AddFirst(prop.Name);
                        }
                    }
                    _map         = _dobject.Map;
                    _currentNode = _propNames.First;

                    if (_currentNode == null)
                    {
                        _dobject       = _dobject.Prototype;
                        _elementsIndex = -1;
                        _current       = null;
                        _map           = null;
                        continue; //Jump to begining of the loop!
                    }
                }
                _current     = _currentNode.Value;
                _currentNode = _currentNode.Next;
                return(true);
            }
            return(false);
        }
Пример #14
0
 public void Remove(System.Collections.Generic.LinkedListNode <T> node) => throw new InvalidOperationException(ExceptionMessages.ReadOnlyCollection);
Пример #15
0
 public System.Collections.Generic.LinkedListNode <T> AddBefore(System.Collections.Generic.LinkedListNode <T> node, T value) => throw new InvalidOperationException(ExceptionMessages.ReadOnlyCollection);
Пример #16
0
        private void ReductionEvent(ReduceEventArgs pValue)
        {
            switch (pValue.Token.Symbol.ToString())
            {
            case "<Value>":
                string Value = "";    //pValue.Token.Tokens[0].ToString().Trim(new char[] { '{', '}' });
                //System.Console.Write(Value);
                this.NodeStack.Push(new TreeNode(Value));
                break;

            case "<Negate Exp>":
                System.Collections.Generic.LinkedListNode <string> Node = new System.Collections.Generic.LinkedListNode <string>("-");
                //System.Console.Write("-");
                TreeNode NegateNode = new TreeNode("-");
                NegateNode.Right = this.NodeStack.Pop();
                this.NodeStack.Push(NegateNode);
                break;

            case "<Add Exp>":
                //System.Console.Write("+");
                TreeNode AddExpNode = new TreeNode("+");
                AddExpNode.Right = this.NodeStack.Pop();
                AddExpNode.Left  = this.NodeStack.Pop();
                this.NodeStack.Push(AddExpNode);
                break;

            case "<Assign_Statement>":
                string Identifier = "";    //args.Token.Tokens[0].ToString().Trim(new char[] { '[', ']' });
                //System.Console.Write(Identifier);
                //System.Console.Write("=");
                TreeNode AssignNode = new TreeNode("=");
                this.TreeList.GetLast().Right = AssignNode;
                AssignNode.Right = this.NodeStack.Pop();
                AssignNode.Left  = new TreeNode(Identifier);
                this.NodeStack.Push(AssignNode);
                break;

            case "<Statement>":
                TreeNode Statement = new TreeNode("statement\n");
                Statement.Right = this.NodeStack.Pop();
                Statement.Left  = this.NodeStack.Pop();
                this.NodeStack.Push(Statement);
                break;

            case "<StatementList>":
                TreeNode StatementList = new TreeNode("sl\n");
                StatementList.Right = this.NodeStack.Pop();
                StatementList.Left  = this.NodeStack.Pop();
                this.NodeStack.Push(StatementList);
                break;

            case "<Program>":
                TreeNode Program = new TreeNode("program");
                Program.Right = this.NodeStack.Pop();
                Program.Left  = this.NodeStack.Pop();
                this.NodeStack.Push(Program);
                break;

            default:
                System.Console.WriteLine(pValue.Token.Symbol.ToString());
                break;
            }
        }
Пример #17
0
        public bool MoveNext()
        {
            // Debug.WriteLine("calling PropertyNameEnumerator.MoveNext");
            while (_dobject != null)
            {
                var array = _dobject as mdr.DArray;
                if (array != null)
                {
                    while (++_elementsIndex < array.ElementsLength)
                    {
                        if (!_visiteds.Contains(-_elementsIndex))
                        {
                            _visiteds.Add(-_elementsIndex);
                            _current = _elementsIndex.ToString();
                            return true;
                        }
                    }
                }

                /*
                ///Spec says the order of retreiving the properties does not matter, so the following code is faster
                ///However some stupid websites (e.g. BBC) count on the fact that Browsers list properties with a certain order
                ///So, we had to change to the slower to be browser compatible, rather than spec compatible
                if (_map == null)
                    _map = _dobject.Map;

                while (_map != null)
                {
                    var prop = _map.Property;
                    _map = _map.Parent;

                    if (!prop.IsNotEnumerable && !_visiteds.Contains(prop.NameId))
                    {
                        _visiteds.Add(prop.NameId);
                        _current = prop.Name;
                        return true;
                    }
                }
                _dobject = _dobject.Prototype;
                _elementsIndex = -1;
                _current = null;
                 */
                if (_currentNode == null)
                {
                    //We may have reached to the end of collected properties, but meanwhile some new ones may have been added
                    _propNames.Clear();
                    if (_map != null && _map != _dobject.Map)
                      _map = _dobject.Map;
                    for (var m = _dobject.Map; m != _map; m = m.Parent)
                    {
                        var prop = m.Property;
                        if (!prop.IsNotEnumerable && !_visiteds.Contains(prop.NameId))
                        {
                          _visiteds.Add(prop.NameId);
                          _propNames.AddFirst(prop.Name);
                        }
                    }
                    _map = _dobject.Map;
                    _currentNode = _propNames.First;

                    if (_currentNode == null)
                    {
                        _dobject = _dobject.Prototype;
                        _elementsIndex = -1;
                        _current = null;
                        _map = null;
                        continue; //Jump to begining of the loop!
                    }
                }
                _current = _currentNode.Value;
                _currentNode = _currentNode.Next;
                return true;
            }
            return false;
        }