Ejemplo n.º 1
0
        public void TestGrowCapacityAndAddMoreElements()
        {
            CCycleArray <int> array = new CCycleArray <int>(3);

            array.Add(1);
            array.Add(2);
            array.Add(3);
            array.Add(4);
            array.Add(5);
            array.Add(6);
            array.Add(7);

            array.Capacity = 5;
            AssertArray(array, 5, 6, 7);
            Assert.AreEqual(5, array.Capacity);
            Assert.AreEqual(7, array.Length);
            Assert.AreEqual(3, array.RealLength);

            array.Add(8);
            array.Add(9);

            Assert.AreEqual(5, array.Capacity);
            Assert.AreEqual(9, array.Length);
            Assert.AreEqual(5, array.RealLength);
            AssertArray(array, 5, 6, 7, 8, 9);
        }
Ejemplo n.º 2
0
        public void TestAddElements2()
        {
            CCycleArray <int> array = new CCycleArray <int>(3);

            array.Add(1);
            array.Add(2);

            Assert.AreEqual(3, array.Capacity);
            Assert.AreEqual(2, array.Length);
            Assert.AreEqual(2, array.RealLength);
            AssertArray(array, 1, 2);
        }
Ejemplo n.º 3
0
        public void TestGrowCapacity()
        {
            CCycleArray <int> array = new CCycleArray <int>(5);

            array.Add(1);
            array.Add(2);
            array.Add(3);

            array.Capacity = 10;

            Assert.AreEqual(10, array.Capacity);
            Assert.AreEqual(3, array.Length);
            Assert.AreEqual(3, array.RealLength);
            AssertArray(array, 1, 2, 3);
        }
Ejemplo n.º 4
0
        public void TestGrowCapacityForOverflowedArrayWithOneExtraElement()
        {
            CCycleArray <int> array = new CCycleArray <int>(3);

            array.Add(1);
            array.Add(2);
            array.Add(3);
            array.Add(4);

            array.Capacity = 10;

            Assert.AreEqual(10, array.Capacity);
            Assert.AreEqual(4, array.Length);
            Assert.AreEqual(3, array.RealLength);
            AssertArray(array, 2, 3, 4);
        }
Ejemplo n.º 5
0
        public void Push(string line)
        {
            if (m_entries.Length == 0 || m_entries[m_entries.Length - 1] != line)
            {
                m_entries.Add(line);
            }

            Reset();
        }
Ejemplo n.º 6
0
        public void TestGrowCapacityAndOverflowMultipleTimes()
        {
            CCycleArray <int> array = new CCycleArray <int>(3);

            for (int i = 0; i < 10; ++i)
            {
                array.Add(i + 1);
            }

            array.Capacity = 5;
            AssertArray(array, 8, 9, 10);

            array.Add(11);
            array.Add(12);

            Assert.AreEqual(5, array.Capacity);
            Assert.AreEqual(12, array.Length);
            Assert.AreEqual(5, array.RealLength);
            AssertArray(array, 8, 9, 10, 11, 12);
        }
Ejemplo n.º 7
0
        public void TestGrowCapacityBiggerArray()
        {
            CCycleArray <int> array = new CCycleArray <int>(7);

            for (int i = 1; i <= 7; ++i)
            {
                array.Add(i);
            }

            array.Capacity = 9;
            AssertArray(array, 1, 2, 3, 4, 5, 6, 7);

            array.Add(8);
            array.Add(9);

            Assert.AreEqual(9, array.Capacity);
            Assert.AreEqual(9, array.Length);
            Assert.AreEqual(9, array.RealLength);
            AssertArray(array, 1, 2, 3, 4, 5, 6, 7, 8, 9);
        }
        private bool ApplyFilter(ICConsoleViewFilter filter)
        {
            int oldIndicesCount = m_filteredIndices.RealLength;

            ClearIndices();

            CConsoleViewCellEntry[] entriesArray = Entries.InternalArray;
            for (int entryIndex = Entries.HeadIndex; entryIndex < Entries.Length; ++entryIndex)
            {
                int entryArrayIndex = Entries.ToArrayIndex(entryIndex);
                if (filter.Apply(ref entriesArray[entryArrayIndex]))
                {
                    m_filteredIndices.Add(entryIndex);
                }
            }

            // TODO: check filtered indices values (indices count can remain the same but lines can change)
            m_oldConsoleEntriesHeadIndex = Entries.HeadIndex;

            return(m_filteredIndices.RealLength != oldIndicesCount ||
                   m_filteredIndices.RealLength != Entries.RealLength);
        }
Ejemplo n.º 9
0
        public void TestAddElements9()
        {
            CCycleArray <int> array = new CCycleArray <int>(3);

            array.Add(1);
            array.Add(2);
            array.Add(3);
            array.Add(4);
            array.Add(5);
            array.Add(6);
            array.Add(7);
            array.Add(8);
            array.Add(9);

            Assert.AreEqual(3, array.Capacity);
            Assert.AreEqual(9, array.Length);
            Assert.AreEqual(3, array.RealLength);
            AssertArray(array, 7, 8, 9);
        }
Ejemplo n.º 10
0
        public void TestGrowCapacityForOverflowedArrayWithFourExtraElements()
        {
            CCycleArray <int> array = new CCycleArray <int>(3);

            array.Add(1);
            array.Add(2);
            array.Add(3);
            array.Add(4);
            array.Add(5);
            array.Add(6);
            array.Add(7);

            array.Capacity = 10;

            Assert.AreEqual(10, array.Capacity);
            Assert.AreEqual(7, array.Length);
            Assert.AreEqual(3, array.RealLength);
            AssertArray(array, 5, 6, 7);
        }
Ejemplo n.º 11
0
        public void TestAddElements6()
        {
            CCycleArray <int> array = new CCycleArray <int>(3);

            array.Add(1);
            array.Add(2);
            array.Add(3);
            array.Add(4);
            array.Add(5);
            array.Add(6);

            Assert.AreEqual(3, array.Capacity);
            Assert.AreEqual(6, array.Length);
            Assert.AreEqual(3, array.RealLength);
            AssertArray(array, 4, 5, 6);
        }
Ejemplo n.º 12
0
 public void Add(CTableViewCell cell)
 {
     m_cells.Add(cell);
 }
Ejemplo n.º 13
0
        public void TestTrimHeadIndex()
        {
            CCycleArray <int> array = new CCycleArray <int>(5);

            array.Add(1);
            array.Add(2);
            array.Add(3);
            array.Add(4);
            array.Add(5);

            array.TrimToHeadIndex(2);

            AssertArray(array, 3, 4, 5);
            Assert.AreEqual(2, array.HeadIndex);
            Assert.AreEqual(5, array.Length);
            Assert.AreEqual(3, array.RealLength);

            array.Add(6);
            array.Add(7);

            AssertArray(array, 3, 4, 5, 6, 7);
            Assert.AreEqual(2, array.HeadIndex);
            Assert.AreEqual(7, array.Length);
            Assert.AreEqual(5, array.RealLength);

            array.Add(8);
            array.Add(9);

            AssertArray(array, 5, 6, 7, 8, 9);
            Assert.AreEqual(4, array.HeadIndex);
            Assert.AreEqual(9, array.Length);
            Assert.AreEqual(5, array.RealLength);

            array.TrimToHeadIndex(7);

            AssertArray(array, 8, 9);
            Assert.AreEqual(7, array.HeadIndex);
            Assert.AreEqual(9, array.Length);
            Assert.AreEqual(2, array.RealLength);

            array.Add(10);
            array.Add(11);

            AssertArray(array, 8, 9, 10, 11);
            Assert.AreEqual(7, array.HeadIndex);
            Assert.AreEqual(11, array.Length);
            Assert.AreEqual(4, array.RealLength);

            array.TrimToHeadIndex(11);

            AssertArray(array);
            Assert.AreEqual(11, array.HeadIndex);
            Assert.AreEqual(11, array.Length);
            Assert.AreEqual(0, array.RealLength);

            array.Add(12);
            array.Add(13);
            array.Add(14);
            array.Add(15);
            array.Add(16);
            array.Add(17);
            array.Add(18);

            AssertArray(array, 14, 15, 16, 17, 18);
            Assert.AreEqual(13, array.HeadIndex);
            Assert.AreEqual(18, array.Length);
            Assert.AreEqual(5, array.RealLength);
        }