private IEnumerator ExtractFromQueue <T>(InfiniteQueue <T> queue, int extractions)
        {
            for (int i = 0; i < extractions; i++)
            {
                yield return(new WaitWhile(() => queue.isEmpty));

                Debug.Log(queue.PopNext());
            }
            Debug.Log($"Count : {queue.count}");
        }
Exemplo n.º 2
0
        public void Test_Generic_InfiniteQueue()
        {
            InfiniteQueue <char> q = new InfiniteQueue <char>();

            char[] ca = ALPHABET.ToCharArray();
            foreach (var c in ca)
            {
                q.Enqueue(c);
            }
            char[]      expected = (ALPHABET + ALPHABET).ToCharArray();
            List <char> test     = new List <char>();

            for (var i = 0; i < ALPHABET.Length * 2; i++)
            {
                test.Add(q.Dequeue());
            }
            char[] actual = test.ToArray();

            Assert.AreEqual(string.Join("", expected), string.Join("", actual));
        }
        private void TryGetInfiniteFloatsRange()
        {
            InfiniteQueue <float> queue = InfiniteFloatPoolInRange(20, -10, 100, RefillPolicy.EMPTY);

            StartCoroutine(ExtractFromQueue(queue, 30));
        }
        private void TryGetInfiniteIntsRange()
        {
            InfiniteQueue <int> queue = InfiniteInt16Pool(10, RefillPolicy.HALF_QUEUE);

            StartCoroutine(ExtractFromQueue(queue, 15));
        }
        private void TryGetInfiniteBool()
        {
            InfiniteQueue <bool> queue = InfiniteBoolPool(10, RefillPolicy.KEEP_FULL);

            StartCoroutine(ExtractFromQueue(queue, 30));
        }