public void UnitRb_Clear() { var rb = new RankedBag <int>(); for (int ix = 0; ix < 50; ++ix) { rb.Add(ix); } Assert.AreEqual(50, rb.Count); int k1 = 0; foreach (var i1 in rb.Reverse()) { ++k1; } Assert.AreEqual(50, k1); rb.Clear(); int k2 = 0; foreach (var i1 in rb.Reverse()) { ++k2; } Assert.AreEqual(0, k2); }
public void UnitRb_EtorCurrentHotUpdate() { var rb1 = new RankedBag <int> { 2 }; var etor1 = rb1.GetEnumerator(); Assert.AreEqual(default(int), etor1.Current); bool ok1 = etor1.MoveNext(); Assert.IsTrue(ok1); Assert.AreEqual(2, etor1.Current); rb1.Remove(2); Assert.AreEqual(2, etor1.Current); var rb2 = new RankedBag <string> { "BB" }; var etor2 = rb2.GetEnumerator(); Assert.AreEqual(default(string), etor2.Current); bool ok2 = etor2.MoveNext(); Assert.AreEqual("BB", etor2.Current); rb2.Clear(); Assert.AreEqual("BB", etor2.Current); }
public void UnitRb_ocCurrent_HotUpdate() { var rb = new RankedBag <int> { 2 }; System.Collections.ICollection oc = rb; System.Collections.IEnumerator etor = oc.GetEnumerator(); bool ok = etor.MoveNext(); Assert.IsTrue(ok); Assert.AreEqual(2, etor.Current); rb.Clear(); Assert.AreEqual(2, etor.Current); }
public void StressRbq_SkipWhile() { var rb = new RankedBag <int> { Capacity = 4 }; int n = 25; for (int x1 = 0; x1 < n; ++x1) { rb.Clear(); for (int x3 = 0; x3 < x1; ++x3) { rb.Add(x3); } System.Collections.Generic.IEnumerable <int> q0 = rb.SkipWhile(x => false); Assert.AreEqual(x1, SLE.Count(q0)); } }
static void Main() { bag = new RankedBag <int>() { Capacity = 6 }; Console.WriteLine("Using Add (x), create tree of order 6:"); for (int ii = 1; ii <= 6; ++ii) { bag.Add(3); } for (int ii = 1; ii <= 13; ++ii) { bag.Add(5); } for (int ii = 1; ii <= 7; ++ii) { bag.Add(7); } for (int ii = 1; ii <= 5; ++ii) { bag.Add(9); } WriteInfo(); Console.WriteLine("Remove (5, 10):"); bag.Remove(5, 13); WriteInfo(); bag.Clear(); Console.WriteLine("Using Add (x, n), create tree of order 6:"); bag.Add(3, 6); bag.Add(5, 13); bag.Add(7, 7); bag.Add(9, 5); WriteInfo(); }
public void CrashRbq_ReverseHotUpdate() { var rb = new RankedBag <int> { Capacity = 4 }; for (int ii = 9; ii >= 0; --ii) { rb.Add(ii); } int a = 0; #if TEST_BCL foreach (var key in Enumerable.Reverse(rb)) #else foreach (var x in rb.Reverse()) #endif { if (++a == 2) { rb.Clear(); } } }