Beispiel #1
0
 public void Format()
 {
     Assert.AreEqual("{  }", coll.ToString());
     coll.AddAll <int>(new int[] { -4, 28, 129, 65530 });
     Assert.AreEqual("{ -4, 65530, 28, 129 }", coll.ToString());
     Assert.AreEqual("{ -4, FFFA, 1C, 81 }", coll.ToString(null, rad16));
     Assert.AreEqual("{ -4, 65530, ... }", coll.ToString("L14", null));
     Assert.AreEqual("{ -4, FFFA, ... }", coll.ToString("L14", rad16));
 }
        public JumpPointParam(JumpPointParam b) : base(b)
        {
            m_heuristic = b.m_heuristic;

            openList = new IntervalHeap <Node>();
            openList.AddAll(b.openList);

            CurIterationType = b.CurIterationType;
        }
Beispiel #3
0
        public JumpPointParam(JumpPointParam b) : base(b)
        {
            m_heuristic = b.m_heuristic;
            CurEndNodeUnWalkableTreatment = b.CurEndNodeUnWalkableTreatment;

            openList = new IntervalHeap <Node>();
            openList.AddAll(b.openList);

            CurIterationType = b.CurIterationType;
        }
Beispiel #4
0
        public JumpPointParam(JumpPointParam b) : base(b)
        {
            m_heuristic = b.m_heuristic;
            m_allowEndNodeUnWalkable = b.m_allowEndNodeUnWalkable;
            m_crossAdjacentPoint     = b.m_crossAdjacentPoint;
            m_crossCorner            = b.m_crossCorner;

            openList = new IntervalHeap <Node>();
            openList.AddAll(b.openList);

            m_useRecursive = b.m_useRecursive;
        }
        /// <summary>
        /// </summary>
        /// <returns>An initial priority queue created for building Huffman tree.</returns>
        private IntervalHeap <HuffmanTreeNode <T> > GetHuffmanNodePriorityQueue(
            HuffmanTreeNodeComparer <T> nodeComparer, Dictionary <T, int> symbolQuantityDic)
        {
            var priorityQueue = new IntervalHeap <HuffmanTreeNode <T> >(nodeComparer);

            priorityQueue.AddAll(symbolQuantityDic.Select(
                                     s => new HuffmanTreeNode <T>(
                                         value: s.Key,
                                         quantity: s.Value
                                         )
                                     ));
            return(priorityQueue);
        }
Beispiel #6
0
        public VoronoiDiagram(IEnumerable <double[]> positions)
        {
            SiteEventQueue = new IntervalHeap <SiteEvent>();
            SiteEventQueue.AddAll(positions.Select(position => new SiteEvent(new Vector3(position[0], position[1], position[2]))));
            SiteEvents = SiteEventQueue.ToList();

            var terminatingPriority = -SiteEventQueue.FindMin().Priority;

            CircleEventQueue = new CircleEventQueue(terminatingPriority);

            Beachline = new Beachline();

            Edges = new EdgeSet(Beachline.Sweepline);
        }
Beispiel #7
0
        public void DeleteAll(Predicate <T> match)
        {
            lock (PriorityQueue)
            {
                Closing = false;
                var all = PriorityQueue.ToList();
                all.RemoveAll(match);

                // Clear all items
                while (PriorityQueue.Count > 0)
                {
                    PriorityQueue.DeleteMax();
                }

                // Add the rest
                PriorityQueue.AddAll(all);
                Monitor.PulseAll(PriorityQueue);
            }
        }
Beispiel #8
0
        private static int ReduceArray(List <int> nums)
        {
            var heap = new IntervalHeap <int>();

            heap.AddAll(nums);

            var cost = 0;

            while (heap.Count > 1)
            {
                var first  = heap.DeleteMin();
                var second = heap.DeleteMin();

                cost += (first + second);

                heap.Add(first + second);
            }

            return(cost);
        }
 public void EnqueueAll(List <ElementType> values)
 {
     inner.AddAll(values);
 }
Beispiel #10
0
        protected void PopulateEventQueue()
        {
            var nextCard = eventDeck.Draw();

            eventQueue.AddAll(nextCard.GenerateEvents());
        }