示例#1
0
        public void OnConsoleEntryAdded(AbstractConsole console, ref ConsoleViewCellEntry entry)
        {
            CycleArray <ConsoleViewCellEntry> 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);
            }
        }
示例#2
0
        public void TestGrowCapacityAndAddMoreElements()
        {
            CycleArray <int> array = new CycleArray <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);
        }
示例#3
0
        public ConsoleFilteredDelegate(ConsoleView consoleView)
        {
            m_consoleView = consoleView;
            m_oldConsoleEntriesHeadIndex = Entries.HeadIndex;

            m_filteredIndices = new CycleArray <int>(consoleView.Entries.Capacity);
        }
        public ConsoleFilteredDelegate(ConsoleView consoleView)
        {
            m_consoleView = consoleView;
            m_oldConsoleEntriesHeadIndex = Entries.HeadIndex;

            m_filteredIndices = new CycleArray<int>(consoleView.Entries.Capacity);
        }
示例#5
0
 private void AssertArray <T>(CycleArray <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]);
     }
 }
        public void AddFirst1()
        {
            CycleArray <int> arr = new CycleArray <int>(32);

            arr.AddFirst(1);

            Assert.AreEqual(1, arr.Count);
            Assert.AreEqual(1, arr[0]);
        }
示例#7
0
        public void TestAddElements()
        {
            CycleArray <int> array = new CycleArray <int>(3);

            array.Add(1);

            Assert.AreEqual(3, array.Capacity);
            Assert.AreEqual(1, array.Length);
            Assert.AreEqual(1, array.RealLength);
            AssertArray(array, 1);
        }
示例#8
0
        public void TestGrowCapacity()
        {
            CycleArray <int> array = new CycleArray <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);
        }
示例#9
0
        public void TestAddElements5()
        {
            CycleArray <int> array = new CycleArray <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);
        }
        public void TestAddFirst()
        {
            CycleArray <int> arr = new CycleArray <int>(32);

            for (int i = 0; i < 32; i++)
            {
                arr.Add(i);
            }

            Assert.AreEqual(32, arr.Count);
            for (int i = arr.Count - 1; i >= 0; i--)
            {
                Assert.AreEqual(i, arr[i]);
            }
        }
示例#11
0
        public void TestGrowCapacityForOverflowedArrayWithOneExtraElement()
        {
            CycleArray <int> array = new CycleArray <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);
        }
        public void TestAdd2()
        {
            CycleArray <int> arr = new CycleArray <int>(32);

            for (int i = 0; i < 32; i++)
            {
                arr.Add(i);
            }
            arr.Add(32);

            Assert.AreEqual(32, arr.Count);
            for (int i = 0; i < arr.Count; i++)
            {
                Assert.AreEqual(i + 1, arr[i]);
            }
        }
示例#13
0
        public void TestAddElements8()
        {
            CycleArray <int> array = new CycleArray <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);
        }
示例#14
0
        public void TestGrowCapacityForOverflowedArrayWithThreeExtraElements()
        {
            CycleArray <int> array = new CycleArray <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);
        }
示例#15
0
        public void TestGrowCapacityAndOverflowMultipleTimes()
        {
            CycleArray <int> array = new CycleArray <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);
        }
        public void TestAddFirst3()
        {
            CycleArray <int> arr = new CycleArray <int>(32);

            for (int i = 0; i < 32; i++)
            {
                arr.Add(31 - i);
            }

            for (int i = 32; i < 100; i++)
            {
                arr.AddFirst(i);
                Assert.AreEqual(32, arr.Count);

                for (int j = 0; j < arr.Count; j++)
                {
                    Assert.AreEqual(i - j, arr[j]);
                }
            }
        }
示例#17
0
        public void TestGrowCapacityBiggerArray()
        {
            CycleArray <int> array = new CycleArray <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);
        }
示例#18
0
        public TableView(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 CycleArray <TableViewCellEntry>(capacity);
            m_visibleCells       = new FastList <TableViewCell>();

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

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

            this.IsFocusable = true;
            this.KeyDown     = KeyDownEventHandler;
            this.KeyUp       = KeyUpEventHandler;
        }
        public void TestDefaults()
        {
            CycleArray <int> arr = new CycleArray <int>(32);

            Assert.AreEqual(0, arr.Count);
        }
示例#20
0
 public TerminalHistory(int capacity)
 {
     m_entries = new CycleArray<string>(capacity);
     m_currentIndex = -1;
 }
 public TestCellCapacityAdapter(int capacity, params TableViewCell[] cells)
 {
     m_cells = new CycleArray<TableViewCell>(capacity);
     Add(cells);
 }
示例#22
0
 public TestCellCapacityAdapter(int capacity, params TableViewCell[] cells)
 {
     m_cells = new CycleArray <TableViewCell>(capacity);
     Add(cells);
 }
 public AbstractConsole(int historySize)
 {
     Entries = new CycleArray<ConsoleViewCellEntry>(historySize);
     Delegate = this; // use null-object to avoid constant null reference checks
 }
示例#24
0
 public TerminalHistory(int capacity)
 {
     m_entries      = new CycleArray <string>(capacity);
     m_currentIndex = -1;
 }
示例#25
0
        public void TestTrimHeadIndex()
        {
            CycleArray <int> array = new CycleArray <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);
        }
 public AbstractConsole(int historySize)
 {
     Entries  = new CycleArray <ConsoleViewCellEntry>(historySize);
     Delegate = this; // use null-object to avoid constant null reference checks
 }