public void OnConsoleEntryAdded(CAbstractConsole console, ref CConsoleViewCellEntry entry)
        {
            CCycleArray <CConsoleViewCellEntry> Entries = this.Entries;

            // if unfiltered console entries overflow - we need to adjust indices and visible lines
            if (m_oldConsoleEntriesHeadIndex < Entries.HeadIndex)
            {
                m_oldConsoleEntriesHeadIndex = Entries.HeadIndex;

                int indicesHeadIndex = m_filteredIndices.HeadIndex;
                while (indicesHeadIndex < m_filteredIndices.Length && m_filteredIndices[indicesHeadIndex] < Entries.HeadIndex)
                {
                    ++indicesHeadIndex;
                }

                m_filteredIndices.TrimToHeadIndex(indicesHeadIndex);
                m_consoleView.TrimCellsToHead(indicesHeadIndex);
            }

            int entryIndex      = Entries.Length - 1;
            int entryArrayIndex = Entries.ToArrayIndex(entryIndex);

            if (Apply(ref Entries.InternalArray[entryArrayIndex]))
            {
                m_filteredIndices.Add(entryIndex);
                m_consoleView.OnConsoleEntryAdded(console, ref entry);
            }
        }
        public CConsoleFilteredDelegate(CConsoleView consoleView)
        {
            m_consoleView = consoleView;
            m_oldConsoleEntriesHeadIndex = Entries.HeadIndex;

            m_filteredIndices = new CCycleArray <int>(consoleView.Entries.Capacity);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
 private void AssertArray <T>(CCycleArray <T> actual, params T[] expected)
 {
     Assert.AreEqual(expected.Length, actual.RealLength);
     for (int i = 0, j = actual.HeadIndex; i < expected.Length; ++i, ++j)
     {
         Assert.AreEqual(expected[i], actual[j]);
     }
 }
Exemplo n.º 5
0
        public void TestAddElements()
        {
            CCycleArray <int> array = new CCycleArray <int>(3);

            array.Add(1);

            Assert.AreEqual(3, array.Capacity);
            Assert.AreEqual(1, array.Length);
            Assert.AreEqual(1, array.RealLength);
            AssertArray(array, 1);
        }
Exemplo n.º 6
0
        public void TestAddElements5()
        {
            CCycleArray <int> array = new CCycleArray <int>(3);

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

            Assert.AreEqual(3, array.Capacity);
            Assert.AreEqual(5, array.Length);
            Assert.AreEqual(3, array.RealLength);
            AssertArray(array, 3, 4, 5);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        public void TestAddElements8()
        {
            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);

            Assert.AreEqual(3, array.Capacity);
            Assert.AreEqual(8, array.Length);
            Assert.AreEqual(3, array.RealLength);
            AssertArray(array, 6, 7, 8);
        }
Exemplo n.º 10
0
        public void TestGrowCapacityForOverflowedArrayWithThreeExtraElements()
        {
            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.Capacity = 10;

            Assert.AreEqual(10, array.Capacity);
            Assert.AreEqual(6, array.Length);
            Assert.AreEqual(3, array.RealLength);
            AssertArray(array, 4, 5, 6);
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
0
        public CTableView(int capacity, float width, float height)
            : base(width, height)
        {
            if (capacity < 0)
            {
                throw new ArgumentException("Negative capacity: " + capacity);
            }

            m_reusableCellsLists = new Dictionary <Type, TableViewCellList>();
            m_cellsEntries       = new CCycleArray <CTableViewCellEntry>(capacity);
            m_visibleCells       = new CFastList <CTableViewCell>();

            this.DataSource    = CTableViewNullDataSource.Instance; // don't do null reference checks
            this.SelectionMode = CTableViewSelectionMode.None;

            this.IsMouseEventsEnabled = true;
            this.MouseDown            = MouseDownEventHandler;
            this.MouseDoubleClick     = MouseDoubleClickHandler;

            this.IsFocusable = true;
            this.KeyDown     = KeyDownEventHandler;
            this.KeyUp       = KeyUpEventHandler;
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
0
 public TestCellCapacityAdapter(int capacity, params CTableViewCell[] cells)
 {
     m_cells = new CCycleArray <CTableViewCell>(capacity);
     Add(cells);
 }
Exemplo n.º 16
0
 public CTerminalHistory(int capacity)
 {
     m_entries = new CCycleArray<string>(capacity);
     m_currentIndex = -1;
 }
Exemplo n.º 17
0
 public CAbstractConsole(int historySize)
 {
     Entries  = new CCycleArray <CConsoleViewCellEntry>(historySize);
     Delegate = this; // use null-object to avoid constant null reference checks
 }