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 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); }