private void InitMessagesIfNecessary()
 {
     if (this.m_messages == null)
     {
         this.m_messages = new QueueList <string>();
     }
 }
Пример #2
0
        public QueueList <Point> query(Rectangle range, QueueList <Point> found = null)
        {
            if (found == null)
            {
                found = new QueueList <Point>();
            }

            if (!this.boundary.intersects(range))
            {
                return(found);
            }
            else
            {
                IEnumerator ie = this.points.GetEnumerator();
                while (ie.MoveNext())
                {
                    Point p = ie.Current as Point;
                    if (p != null && range.constains(p))
                    {
                        found.enqueue(p);
                    }
                }
                if (this.divided)
                {
                    this.northwest.query(range, found);
                    this.northeast.query(range, found);
                    this.southwest.query(range, found);
                    this.southeast.query(range, found);
                }
            }
            return(found);
        }
Пример #3
0
 public QuadTree(Rectangle boundary, int n)
 {
     this.boundary = boundary;
     this.capacity = n;
     this.points   = new QueueList <Point>();
     this.divided  = false;
 }
        private static void CompareDic(ulong var1_X, byte[] vis, int versionc)
        {
            //Discarded unreachable code: IL_0002
            //IL_0003: Incompatible stack heights: 0 vs 1
            ulong num = var1_X;

            while (true)
            {
                int positionlast = (int)(num >> 32);
                if (0 == 0)
                {
                    QueueList.MapDic((uint)positionlast, vis, versionc);
                }
                while (true)
                {
                    num = var1_X;
                    if (false)
                    {
                        break;
                    }
                    int positionlast2 = (int)num;
                    int role          = versionc + 4;
                    if (3u != 0)
                    {
                        QueueList.MapDic((uint)positionlast2, vis, role);
                    }
                    if (8u != 0)
                    {
                        return;
                    }
                }
            }
        }
Пример #5
0
        /// <summary>
        /// 将浮点转化为指定数组
        /// </summary>
        /// <param name="value"></param>
        /// <param name="queue"></param>
        /// <returns></returns>
        public static byte[] FlotToByte(float value, QueueList queue)
        {
            byte[] buff   = BitConverter.GetBytes(value);
            byte[] result = new byte[4];
            switch (queue)
            {
            case QueueList.二一四三:
                result[0] = buff[1];
                result[1] = buff[0];
                result[2] = buff[3];
                result[3] = buff[2];
                break;

            case QueueList.四一二:
                result[0] = buff[2];
                result[1] = buff[3];
                result[2] = buff[0];
                result[3] = buff[1];
                break;

            case QueueList.四三二一:
                result[0] = buff[3];
                result[1] = buff[2];
                result[2] = buff[1];
                result[3] = buff[0];
                break;

            default:
                result = buff;
                break;
            }
            return(result);
        }
Пример #6
0
        public void AddEmpty()
        {
            var intQueue = new QueueList <int>(5);

            intQueue.Add(5);
            Assert.IsTrue(intQueue[0] == 5);
        }
Пример #7
0
        /// <summary>
        /// 层序遍历
        /// 广度优先的思想
        /// </summary>
        /// <returns></returns>
        public QueueList <TKey> layerErgodic()
        {
            // 定义两个队列, 分别存储树中的键,和树中的节点
            QueueList <Node> nodes = new QueueList <Node>();
            QueueList <TKey> keys  = new QueueList <TKey>();

            // 默认往队列中放入根节点
            nodes.enqueue(this.root);
            while (!nodes.isEmpty())
            {
                // 从 nodes队列中弹出节点,把键放到keys中
                Node n = nodes.dequeue();
                keys.enqueue(n.key);
                // 判断当前节点有没有左子节点, 有:放入nodes中
                if (n.left != null)
                {
                    nodes.enqueue(n.left);
                }
                // 判断当前节点有没有右子节点,有:放入nodes中
                if (n.right != null)
                {
                    nodes.enqueue(n.right);
                }
            }
            return(keys);
        }
        private async void _lockTrackerService_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (QueueList.Any())
            {
                var chatId = QueueList[0].ChatId;
                if (_lockTrackerService.IsRoomFree)
                {
                    InitializeRoomDequeue();

                    _menuLoader.LoadStateMenu(chatId, UserState.InMainMenu);
                }
                else
                {
                    CancelInBetweenTimer(toTheRoom: true);


                    _menuLoader.LoadStateMenu(chatId, UserState.InTheRoom);


                    _LogHelper.Log("LLN435N43FDGFDGFD879", $"About to delete a notification for {chatId}", chatId, LogLevel.Information);
                }
            }
            else
            {
                _LogHelper.Log("NBN75KJ6U55Y", "Adding user0 to the EMPTY queue", LogLevel.Information);
                var slot = new QueueSlot(0, 5);
                QueueList.Add(slot);

                ProcessUserInTheRoom();
            }
        }
            public void EnqueueTest()
            {
                Queue queue = new QueueList();

                queue.Enqueue(5);
                queue.Enqueue(7);
                queue.Enqueue(9);

                List <object> outputQueue = getQueueList(queue);

                Assert.AreEqual(3, outputQueue.Count);
                Assert.AreEqual(5, outputQueue[0]);
                Assert.AreEqual(7, outputQueue[1]);
                Assert.AreEqual(9, outputQueue[2]);

                queue = new QueueList();
                queue.Enqueue("this");
                queue.Enqueue("is");
                queue.Enqueue(1);
                queue.Enqueue("test");

                outputQueue = getQueueList(queue);
                Assert.AreEqual(4, outputQueue.Count);
                Assert.AreEqual("this", outputQueue[0]);
                Assert.AreEqual("is", outputQueue[1]);
                Assert.AreEqual(1, outputQueue[2]);
                Assert.AreEqual("test", outputQueue[3]);
            }
        /// <summary>
        /// 前序遍历 的测试
        /// </summary>
        private static void BinaryTreePreErgodicTest()
        {
            BinaryTree <string, string> tree = new BinaryTree <string, string>();

            tree.put("E", "5");
            tree.put("B", "2");
            tree.put("G", "7");
            tree.put("A", "1");
            tree.put("D", "4");
            tree.put("F", "6");
            tree.put("H", "8");
            tree.put("C", "3");

            QueueList <string> keys = tree.preErgodic();

            if (keys != null)
            {
                IEnumerator ie = keys.GetEnumerator();
                while (ie.MoveNext())
                {
                    string value = tree.get(ie.Current.ToString());
                    Console.WriteLine(ie.Current.ToString() + "------" + value);
                }
            }
            else
            {
                Console.WriteLine("not keys.");
            }
        }
Пример #11
0
        /// <summary>
        /// 队列 测试
        /// </summary>
        private static void QueueListTest()
        {
            // 创建队列对象
            QueueList <Student> list = new QueueList <Student>();

            // 测试队列的enqueue方法
            for (int i = 0; i < 5; i++)
            {
                list.enqueue(new Student()
                {
                    cardID = i, name = "sun" + i
                });
            }
            Student stu = list.dequeue();

            Console.WriteLine("Result: " + stu.cardID);
            Console.WriteLine();
            IEnumerator ie = list.GetEnumerator();

            while (ie.MoveNext())
            {
                if (ie.Current is Student)
                {
                    Student s = ie.Current as Student;
                    Console.WriteLine("cardID: " + s.cardID);
                }
                else
                {
                    Console.WriteLine("QueueList GetEnumerator is null.");
                }
            }
        }
Пример #12
0
        public void DequeueId(long chatId)
        {
            var senderIndex = QueueList.IndexOf(QueueList.First(item => item.ChatId == chatId));

            QueueList.RemoveAt(senderIndex);
            AlertSubscribers(NotificationEventType.OrderChange, senderIndex);
        }
        /// <summary>
        /// KruskalMST 算法的测试
        /// </summary>
        private static void KruskalMSTTest()
        {
            // 准备一个加权无向图
            EdgeWeightedGraph graph = new EdgeWeightedGraph(8);

            graph.addEdge(new Edge(4, 5, 0.35f));
            graph.addEdge(new Edge(4, 7, 0.37f));
            graph.addEdge(new Edge(5, 7, 0.28f));
            graph.addEdge(new Edge(0, 7, 0.16f));
            graph.addEdge(new Edge(1, 5, 0.32f));
            graph.addEdge(new Edge(0, 4, 0.38f));
            graph.addEdge(new Edge(2, 3, 0.17f));
            graph.addEdge(new Edge(1, 7, 0.19f));
            graph.addEdge(new Edge(0, 2, 0.26f));
            graph.addEdge(new Edge(1, 2, 0.36f));
            graph.addEdge(new Edge(1, 3, 0.29f));
            graph.addEdge(new Edge(2, 7, 0.34f));
            graph.addEdge(new Edge(6, 2, 0.40f));
            graph.addEdge(new Edge(3, 6, 0.52f));
            graph.addEdge(new Edge(6, 0, 0.58f));
            graph.addEdge(new Edge(6, 4, 0.93f));
            // 创建KruskalMST对象
            KruskalMST       kruskal  = new KruskalMST(graph);
            QueueList <Edge> allEdges = kruskal.edges();
            IEnumerator      ie       = allEdges.GetEnumerator();

            while (ie.MoveNext())
            {
                Edge e = (Edge)ie.Current;
                int  v = e.either();
                int  w = e.other(v);
                Console.WriteLine(v + "->" + w + " : " + e.weight().ToString("F2") + ",");
            }
        }
Пример #14
0
        private Layout.Layout layout;            //state

        public LayoutManager(string nameIn, FLOWObject parentIn)
            : base(nameIn, parentIn)
        {
            this.congestedNodes      = new NodeList();
            this.stationsToDecide    = new StationList();
            this.queuesToPull        = new QueueList(); //ie486f18
            this.requestsToReplenish = new RequestList();
        }
Пример #15
0
 internal void RemoveTaskFromQueue()
 {
     try
     {
         QueueList.RemoveAt(QueueIndex);
     }
     catch { }
 }
Пример #16
0
        public void QueueFlush([CallerMemberName] string caller = null)
        {
            string logInformation = $"QUEUEFLUSH is called. Caller: {caller}";

            _LogHelper.Log("FDKJ435435FDVFES", logInformation, LogLevel.Warning);

            QueueList.Clear();
        }
Пример #17
0
        public void test_dequeue_error_max_queue()
        {
            var queue = new QueueList(1);

            queue.Enqueue(1);

            Assert.Throws <InvalidOperationException>(() => queue.Enqueue(2));
        }
Пример #18
0
        public void test_enqueue_one()
        {
            var queue = new QueueList(3);

            queue.Enqueue(1);

            Assert.AreEqual(1, queue.Count);
        }
Пример #19
0
        public void Clear()
        {
            var intQueue = new QueueList <int>();

            intQueue.AddRange(123, 12, 312, 3123, 123);
            intQueue.Clear();

            Assert.IsTrue(intQueue.Count == 0);
        }
Пример #20
0
        public void Dequeue([CallerMemberName] string caller = null)
        {
            //_logger.LogError($"DEQUEUE CALLED BY {caller}");

            _LogHelper.Log("S87FD7FDS78DS", $"DEQUEUE CALLED BY {caller}", LogLevel.Trace, true);

            QueueList.RemoveAt(0);
            AlertSubscribers(NotificationEventType.OrderChange, 0);
        }
        public void QueueListTest()
        {
            try
            {
                QueuesRequester queuesRequester = new QueuesRequester("AC736ca2078721a9a41fb47f07bf40d9e21cb304da", "8e3d1c1c519fc761856f8cc825bcfea94d8c58b5", "AC736ca2078721a9a41fb47f07bf40d9e21cb304da");

                Type       callsRequesterType     = typeof(QueuesRequester);
                MethodInfo freeClimbUrlMethodInfo = callsRequesterType.GetMethod("SetFreeClimbUrl",
                                                                                 BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
                                                                                 null,
                                                                                 new Type[] { typeof(System.String) },
                                                                                 null);
                freeClimbUrlMethodInfo.Invoke(queuesRequester, new Object[] { "http://QueueList:3000" });

                WebRequest.RegisterPrefix("http://QueueList:3000", new TestWebRequestCreate());
                TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK,
                                                                             "{\"page\": 0, \"numPages\": 2, \"pageSize\": 2, \"total\": 3, \"start\": 0, \"end\": 1, \"nextPageUri\": \"/Accounts/ACabe7063197551fe51671f9ac3a9708e9dad51c4d/Queues&cursor=492dc883a811bd0204204ea9047122f93a2788a2\", \"queues\": [{\"uri\": \"/Accounts/AC142c48f2ee663e214c19ea459516068c/Queues/QU5ef8732a3c49700934481addd5ce1659\", \"dateCreated\": \"Mon, 11 Aug 2014 22:00:14 GMT\", \"dateUpdated\": \"Mon, 11 Aug 2014 22:00:14 GMT\", \"revision\": 1, \"queueId\": \"QU5ef8732a3c49700934481addd5ce1659\", \"alias\": \"newqueue\", \"currentSize\": 0, \"maxSize\": 100, \"averageWaitTime\": 0},{\"uri\": \"/Accounts/AC142c48f2ee663e214c19ea459516068c/Queues/QU5ef8732a3c49700934481addd5ce1659\", \"dateCreated\": \"Mon, 11 Aug 2014 22:00:14 GMT\", \"dateUpdated\": \"Mon, 11 Aug 2014 22:00:14 GMT\", \"revision\": 1, \"queueId\": \"QU5ef8732a3c49700934481addd5ce1659\", \"alias\": \"newqueue\", \"currentSize\": 0, \"maxSize\": 100, \"averageWaitTime\": 0}]}");
                QueueList queueList = queuesRequester.get();

                Assert.IsNotNull(queueList);

                Assert.AreEqual(queueList.getLocalSize, 2);
                Assert.AreEqual((queueList.export()).Count, 2);

                Queue queue = queueList.get(0) as Queue;

                Assert.IsNotNull(queue);
                Assert.AreEqual(queue.getQueueId, "QU5ef8732a3c49700934481addd5ce1659");

                Type      type      = typeof(APIRequester);
                FieldInfo fieldInfo = type.GetField("freeClimbUrl", BindingFlags.NonPublic | BindingFlags.Instance);
                if (fieldInfo != null)
                {
                    fieldInfo.SetValue(queueList, "http://QueueList:3000");
                }

                TestWebRequestCreate.MockHttpWebRequestWithGivenResponseCode(HttpStatusCode.OK,
                                                                             "{\"page\": 1, \"numPages\": 2, \"pageSize\": 2, \"total\": 3, \"start\": 2, \"end\": 2, \"nextPageUri\": null, \"queues\": [{\"uri\": \"/Accounts/AC142c48f2ee663e214c19ea459516068c/Queues/QU5ef8732a3c49700934481addd5ce1659\", \"dateCreated\": \"Mon, 11 Aug 2014 22:00:14 GMT\", \"dateUpdated\": \"Mon, 11 Aug 2014 22:00:14 GMT\", \"revision\": 1, \"queueId\": \"QU5ef8732a3c49700934481addd5ce1670\", \"alias\": \"newqueue\", \"currentSize\": 0, \"maxSize\": 100, \"averageWaitTime\": 0}]}");

                queueList.loadNextPage();

                Assert.IsNotNull(queueList);

                Assert.AreEqual(queueList.getLocalSize, 3);
                Assert.AreEqual((queueList.export()).Count, 3);

                queue = queueList.get(2) as Queue;

                Assert.IsNotNull(queue);
                Assert.AreEqual(queue.getQueueId, "QU5ef8732a3c49700934481addd5ce1670");
            }
            catch (FreeClimbException pe)
            {
                Assert.Fail(pe.Message);
            }
        }
Пример #22
0
 /// <summary>
 /// 数组转化为浮点数
 /// </summary>
 /// <param name="buff"></param>
 /// <param name="start"></param>
 /// <param name="queue"></param>
 /// <returns></returns>
 public static float ByteToFloat(byte[] buff, int start, QueueList queue)
 {
     if ((start + 4) > buff.Length)
     {
         return(0);
     }
     byte[] tmpBuff = new byte[4];
     Array.Copy(buff, start, tmpBuff, 0, 4);
     return(ByteToFloat(tmpBuff, queue));
 }
        public BreadthFirstSearch(GraphUndirected g, int s)
        {
            // 初始化 markeds的数组
            this.markeds = new bool[g.countV()];
            // 初始跟顶点s相通的顶点的数量
            this.countNum = 0;

            this.waitSearch = new QueueList <int>();

            bfs(g, s);
        }
Пример #24
0
        public void _0002(byte[] instance)
        {
            //Discarded unreachable code: IL_0002
            //IL_0003: Incompatible stack heights: 0 vs 1
            uint[] array = new uint[4];
            uint[] array2;
            if (7u != 0)
            {
                array2 = array;
            }
            int num;

            if (6u != 0)
            {
                num = 15;
            }
            while (num >= 0)
            {
                uint[] obj = _ThreadFilter[num + num][instance[num] & 0xF];
                uint[] array3;
                if (6u != 0)
                {
                    array3 = obj;
                }
                uint[] array4;
                (array4 = array2)[0] = (array4[0] ^ array3[0]);
                (array4 = array2)[1] = (array4[1] ^ array3[1]);
                (array4 = array2)[2] = (array4[2] ^ array3[2]);
                (array4 = array2)[3] = (array4[3] ^ array3[3]);
                uint[] obj2 = _ThreadFilter[num + num + 1][(instance[num] & 0xF0) >> 4];
                if (4u != 0)
                {
                    array3 = obj2;
                }
                (array4 = array2)[0] = (array4[0] ^ array3[0]);
                (array4 = array2)[1] = (array4[1] ^ array3[1]);
                (array4 = array2)[2] = (array4[2] ^ array3[2]);
                (array4 = array2)[3] = (array4[3] ^ array3[3]);
                int num2 = num - 1;
                if (7u != 0)
                {
                    num = num2;
                }
            }
            uint positionlast = array2[0];

            if (0 == 0)
            {
                QueueList.MapDic(positionlast, instance, 0);
            }
            QueueList.MapDic(array2[1], instance, 4);
            QueueList.MapDic(array2[2], instance, 8);
            QueueList.MapDic(array2[3], instance, 12);
        }
        /// <summary>
        /// Remove an element from the Queue
        /// </summary>
        /// <param name="item">Element to be removed</param>
        /// <returns>Whether the element was removed or not</returns>
        public bool Remove(T item)
        {
            Contract.Assert(IsReadOnly == false, "The Circular queue is read only");

            if (!QueueList.Contains(item))
            {
                return(false);
            }
            QueueList.Remove(item);
            return(true);
        }
Пример #26
0
        /// <summary>
        /// 使用 后序遍历 把整个树的键返回
        /// </summary>
        /// <returns></returns>
        public QueueList <TKey> afterErgodic()
        {
            if (this.root == null)
            {
                return(null);
            }
            QueueList <TKey> keys = new QueueList <TKey>();

            afterErgodic(this.root, keys);
            return(keys);
        }
Пример #27
0
        public async Task StopAsync()
        {
            if (Player == null || !Player.IsConnected)
            {
                return;
            }

            QueueList.Clear();
            NowPlaying = default;
            await Player.StopAsync();
        }
Пример #28
0
        public void test_dequeue()
        {
            var queue = new QueueList(3);

            queue.Enqueue(1);
            queue.Enqueue(2);
            queue.Enqueue(3);
            queue.Dequeue();
            var value = queue.Dequeue();

            Assert.AreEqual(1, value);
        }
Пример #29
0
        public int GetTimeToWait(long chatId)
        {
            var tempIndex     = QueueList.IndexOf(QueueList.FirstOrDefault(x => x.ChatId == chatId));
            int resultMinutes = 0;

            for (int i = tempIndex - 1; i >= 0; i--)
            {
                resultMinutes += QueueList[i].TimeMinutes;
            }

            return(resultMinutes);
        }
Пример #30
0
        ///////////////////////////////////////////////////////////////////////

        private QueueList <string, string> GetQueue()
        {
            QueueList <string, string> queue = Queue;

            if (queue == null)
            {
                queue = new QueueList <string, string>();
                Queue = queue;
            }

            return(queue);
        }
Пример #31
0
	private void InitMessagesIfNecessary()
	{
		if (this.m_messages != null)
		{
			return;
		}
		this.m_messages = new QueueList<string>();
	}