Exemplo n.º 1
0
        public void Dispose()
        {
            isDisposing = true;

            disposedToUnregister.Clear();

            foreach (var sys in systemList)
            {
                if (sys is IDisposable disposable)
                {
                    disposable.Dispose();
                }
            }

            systemList.Clear();
            systemList = null;

            systemMap.Clear();
            systemMap = null;

            availablePasses.Clear();
            passToLoop.Clear();

            ExecutingRegister = null;
        }
Exemplo n.º 2
0
        public void ClearTest()
        {
            var list = new OrderedList <int>(new int[] { 10, 5, 7, 5, 2, 15 });

            Assert.AreEqual(6, list.Count);

            list.Clear();
            Assert.AreEqual(0, list.Count);

            Assert.IsFalse(list.IsReadOnly);
        }
Exemplo n.º 3
0
        public void ClearTest()
        {
            OrderedList <int> orderedListAsc = CreateOrderedList(
                true,
                0, 9, 8, 1, 2, 3, 7, 6, 5, 4);

            orderedListAsc.Clear(true);

            Assert.Null(orderedListAsc.head);
            Assert.Null(orderedListAsc.tail);
        }
Exemplo n.º 4
0
        public void Clear_FlushesTheList()
        {
            TestItem item2 = new TestItem(2);
            TestItem item7 = new TestItem(7);

            list.Add(item7);
            list.Add(item2);
            Assert.AreEqual(2, list.Count);

            list.Clear();

            Assert.AreEqual(0, list.Count);
        }
Exemplo n.º 5
0
        public void TestClearAsc()
        {
            var stack = new OrderedList <int>(true);

            stack.Add(1);
            stack.Add(3);
            stack.Add(5);
            stack.Add(0);
            stack.Add(2);
            stack.Add(7);
            stack.Add(4);
            stack.Add(4);

            stack.Clear(true);
            Assert.True(stack.Count() == 0);
            stack.Add(1);
            stack.Add(2);

            Assert.True(stack.ToString().Equals("1 2"));
            Assert.True(stack.Count() == 2);
        }
Exemplo n.º 6
0
        private bool TryProcessPage(ContentObject page, IEnumerable <IContentProcessor> pageProcessors, OrderedList <IContentProcessor> pendingPageProcessors, bool copyOutput)
        {
            // If page is discarded, skip it
            if (page.Discard)
            {
                return(false);
            }

            // By default working on all processors
            // Order is important!
            pendingPageProcessors.AddRange(pageProcessors);
            bool hasBeenProcessed = true;
            bool breakProcessing  = false;

            // We process the page going through all IContentProcessor from the end of the list
            // (more priority) to the beginning of the list (less priority).
            // An IContentProcessor can transform the page to another type of content
            // that could then be processed by another IContentProcessor
            // But we make sure that a processor cannot process a page more than one time
            // to avoid an infinite loop
            var clock = Stopwatch.StartNew();

            while (hasBeenProcessed && !breakProcessing && !page.Discard)
            {
                hasBeenProcessed = false;
                for (int i = pendingPageProcessors.Count - 1; i >= 0; i--)
                {
                    var processor = pendingPageProcessors[i];

                    // Note that page.ContentType can be changed by a processor
                    // while processing a page
                    clock.Restart();
                    try
                    {
                        var result = processor.TryProcess(page);

                        if (result != ContentResult.None)
                        {
                            // Update statistics per plugin
                            var statistics = Site.Statistics;
                            var stat       = statistics.GetPluginStat(processor);
                            stat.PageCount++;
                            stat.ContentProcessTime += clock.Elapsed;

                            hasBeenProcessed = true;
                            pendingPageProcessors.RemoveAt(i);
                            breakProcessing = result == ContentResult.Break;
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        Site.Error(ex, $"Error while processing {page.Path}.");
                        breakProcessing  = true;
                        hasBeenProcessed = true;
                        break;
                    }
                }
            }
            pendingPageProcessors.Clear();

            // Copy only if the file are marked as include
            if (copyOutput && !breakProcessing && !page.Discard)
            {
                Site.Content.TryCopyContentToOutput(page, page.GetDestinationPath());
            }

            return(true);
        }
Exemplo n.º 7
0
 public void RemoveAllMarks()
 {
     _marks.Clear();
 }
Exemplo n.º 8
0
        public IList <PointInt32> FindPath(IMover mover, PointInt32 start, PointInt32 target)
        {
            if (m_Map.IsBlocked(mover, target))
            {
                return(null);
            }
            m_Nodes.Clear();
            m_Nodes[start].Cost  = 0f;
            m_Nodes[start].Depth = 0;
            m_Closed.Clear();
            m_Open.Clear();
            m_Open.Add(m_Nodes[start]);
            m_Nodes[target].Parent = null;
            int maxDepth = 0;

            while ((maxDepth < m_MaxSearchDistance) && (m_Open.Count != 0))
            {
                var current = m_Open.First();
                if (current == m_Nodes[target])
                {
                    break;
                }
                m_Open.Remove(current);
                m_Closed.Add(current);
                for (int x = -1; x < 2; x++)
                {
                    for (int y = -1; y < 2; y++)
                    {
                        if (((x != 0) || (y != 0)) && (m_AllowDiagMovement || ((x == 0) || (y == 0))))
                        {
                            var point = new PointInt32(current.Point.X + x, current.Point.Y + y);
                            if (IsValidLocation(mover, start, point))
                            {
                                float nextStepCost = current.Cost + m_Map.GetCost(mover, current.Point, point);
                                var   neighbour    = m_Nodes[point];
                                m_Map.PathfinderCallback(point);
                                if (nextStepCost < neighbour.Cost)
                                {
                                    if (m_Open.Contains(neighbour))
                                    {
                                        m_Open.Remove(neighbour);
                                    }
                                    if (m_Closed.Contains(neighbour))
                                    {
                                        m_Closed.Remove(neighbour);
                                    }
                                }
                                if (!(m_Open.Contains(neighbour) || m_Closed.Contains(neighbour)))
                                {
                                    neighbour.Cost      = nextStepCost;
                                    neighbour.Heuristic = m_Heuristic.GetCost(m_Map, mover, point, start, target);
                                    maxDepth            = System.Math.Max(maxDepth, neighbour.SetParent(current));
                                    m_Open.Add(neighbour);
                                }
                            }
                        }
                    }
                }
            }
            if (m_Nodes[target].Parent == null)
            {
                return(null);
            }
            var path = new List <PointInt32>();

            for (var targetNode = m_Nodes[target]; targetNode != m_Nodes[start]; targetNode = targetNode.Parent)
            {
                path.Insert(0, targetNode.Point);
            }
            path.Insert(0, start);
            return(path);
        }