public void Setup() { _dict = new IterableDict <int, int>(); for (int i = 0; i < _length; i++) { _dict.AddOrUpdate(i, i * 10); } }
static void Main(string[] args) { _dict = new IterableDict<int, int>(); for (int i = 0; i < len; i++) { _dict.AddOrUpdate(i, i); } var t1 = Task.Run(() => Manipulate()); var t2 = Task.Run(() => Read()); //Task.WaitAll(t1, t2); Console.ReadLine(); }
public void ModifyNextNode() { var cursor1 = _dict.GetCursor(); var cursor1Read = new Dictionary <int, int>(); IterableLinkedListNode <int> curr; // read Assert.IsTrue(cursor1.MoveNext(), "Couldn't read next"); curr = cursor1.GetCurrentNode(); Assert.IsNotNull(curr?.Value); cursor1Read.AddOrUpdate(curr.Value, _dict[curr.Value]); // read Assert.IsTrue(cursor1.MoveNext(), "Couldn't read next"); curr = cursor1.GetCurrentNode(); Assert.IsNotNull(curr?.Value); cursor1Read.Add(curr.Value, _dict[curr.Value]); // update next node _dict.AddOrUpdate(2, _dict[2] * 2); // read the rest while (cursor1.MoveNext()) { curr = cursor1.GetCurrentNode(); Assert.IsNotNull(curr?.Value); cursor1Read.AddOrUpdate(curr.Value, _dict[curr.Value]); } // read from beginning with a new cursor var cursor2 = _dict.GetCursor(); var cursor2Read = new Dictionary <int, int>(); while (cursor2.MoveNext()) { curr = cursor2.GetCurrentNode(); Assert.IsNotNull(curr?.Value); cursor2Read.AddOrUpdate(curr.Value, _dict[curr.Value]); } // Check we got the same foreach (var pair in cursor1Read) { Assert.IsTrue(cursor2Read.ContainsKey(pair.Key)); Assert.AreEqual(cursor2Read[pair.Key], pair.Value); } }