Exemplo n.º 1
0
        private IEnumerable <placement> GetAvailableVerticalPlacements(int len)
        {
            var res = new List <List <Square> >();

            for (int c = 0; c < Cl; ++c)
            {
                limitedQueue <Square> pass = new limitedQueue <Square>(len);
                for (int r = 0; r < Rw; ++r)
                {
                    if (IsAvailable(r, c))
                    {
                        pass.Enqueue(squares[r, c]);
                    }
                    else
                    {
                        pass.Clear();
                    }
                    if (pass.Count == len)
                    {
                        res.Add(pass.ToList());
                    }
                }
            }
            return(res);
        }
Exemplo n.º 2
0
        public void AddingItemsBehindLimitRemovesFifo()
        {
            limitedQueue <int> q = new limitedQueue <int>(3);

            Assert.AreEqual(0, q.Count);
            q.Enqueue(1);
            Assert.AreEqual(1, q.Count);
            q.Enqueue(2);
            Assert.AreEqual(2, q.Count);
            q.Enqueue(3);
            Assert.AreEqual(3, q.Count);
            q.Enqueue(4);
            Assert.AreEqual(3, q.Count);
            Assert.IsFalse(q.Contains(1));
            Assert.IsTrue(q.Contains(4));
        }