public void TestRemoveInt() { IntListContainer list1 = new IntListContainer(0, 1, 2, 3, 4, 5, 6, 6); Assert.IsTrue(list1.Remove(6)); Assert.IsTrue(list1.Remove(6)); Assert.IsFalse(list1.Contains(6)); IntListContainer list2 = new IntListContainer(); Assert.IsFalse(list2.Remove(0)); }
public void TestRemoveList() { IntListContainer list1 = new IntListContainer(0, 1, 2, 3, 4, 5, 6, 6, 7); IntListContainer blackList = new IntListContainer(6, 7, 6); Assert.IsTrue(list1.Remove(blackList)); Assert.IsFalse(list1.Contains(6)); Assert.IsFalse(list1.Contains(7)); for (int i = 0; i < 6; ++i) { Assert.IsTrue(list1.Contains(i)); } list1.Remove(new IntListContainer()); for (int i = 0; i < 6; ++i) { Assert.IsTrue(list1.Contains(i)); } }
/// <summary> /// Remove all values in array below certain count /// </summary> public static void RemoveValuesAboveValue(this IntListContainer container, int value) { List <int> removeValues = new List <int>(); for (int i = 0; i < container.Count; ++i) { if (container[i] > value) { removeValues.Add(container[i]); } } for (int i = 0; i < removeValues.Count; ++i) { container.Remove(removeValues[i]); } }