public void UnitRb_RemoveAll() { var rb0 = new RankedBag <int>(); var rb = new RankedBag <int> { Capacity = 4 }; foreach (var ii in new int[] { 3, 5, 5, 7, 7 }) { rb.Add(ii); } int rem0 = rb0.RemoveAll(new int[] { 2 }); Assert.AreEqual(0, rem0); int rem1 = rb.RemoveAll(new int[] { }); Assert.AreEqual(0, rem1); int rem2 = rb.RemoveAll(new int[] { 2 }); Assert.AreEqual(0, rem0); int rem57 = rb.RemoveAll(new int[] { 5, 7 }); Assert.AreEqual(2, rem57); Assert.IsTrue(System.Linq.Enumerable.SequenceEqual(new int[] { 3, 5, 7 }, rb)); int rem4 = rb.RemoveAll(rb); Assert.AreEqual(3, rem4); Assert.AreEqual(0, rb.Count); }
static void Main() { bag = new RankedBag <int>() { Capacity = 4 }; Console.WriteLine("Create tree of order 4:"); for (int i = 2; i <= 12; i += 2) { bag.Add(i); } for (int i = 2; i <= 12; i += 2) { bag.Add(i); } for (int i = 2; i <= 12; i += 2) { bag.Add(i); } for (int i = 2; i <= 12; i += 2) { bag.Add(i); } WriteInfo(); var a1 = new int[] { 4, 6, 6, 6 }; Console.WriteLine("\nRemoveAll " + String.Join(",", a1) + ":"); bag.RemoveAll(a1); WriteInfo(); Console.WriteLine("\nRemoveAll 8:"); bag.RemoveAll(new int[] { 8 }); WriteInfo(); Console.WriteLine("\nRemoveAll 8:"); bag.RemoveAll(new int[] { 8 }); WriteInfo(); Console.WriteLine("GetCount(12) = " + bag.GetCount(12)); var a2 = new int[] { 1, 2, 2, 5, 10, 21 }; Console.WriteLine("\nRetain " + String.Join(",", a2) + ":"); bag.RetainAll(a2); WriteInfo(); }
public void CrashRb_RemoveAll_ArgumentNull() { var rb = new RankedBag <int>(); rb.RemoveAll(null); }