/// <summary> /// adds <paramref name="inputEntry"/> to input history. /// if <see cref="Capacity"/> is reached, the least recent entry is removed to make room /// for <paramref name="inputEntry"/>. /// </summary> /// <param name="inputEntry">input entry to be inserted to input history</param> public void AddInputEntryToHistory(string inputEntry) { // avoid adding consecutive duplicate entries to stack bool addInputEntry = recentInputEntries.Empty || inputEntry != recentInputEntries.TopElement(); if (addInputEntry) { recentInputEntries.Push(inputEntry); } }
static void AddItems(IndexableStack<int> queue, IList<int> items) { int initialCount = queue.Count; foreach(int i in items) queue.Push(i); Assert.AreEqual(initialCount+items.Count, queue.Count); }