public Buckets <int> Run(Buckets <int> buckets) { var leftValue = buckets.Get(_leftBucket); var rightValue = buckets.Get(_rightBucket); return(buckets.Set(_outBucket, leftValue - rightValue)); }
public void TestBucketsIncrementAndGetAndSet() { var b = new Buckets(5, 2); var incrementedB = b.Increment(0, 1); Assert.AreSame(b, incrementedB, "Returned Buckets should be the same instance"); var v = b.Get(0); Assert.AreEqual(1u, v); b.Increment(1u, -1); v = b.Get(1); Assert.AreEqual(0u, v); var setB = b.Set(2u, 100); Assert.AreSame(b, setB, "Returned Buckets should be the same instance"); v = b.Get(2); Assert.AreEqual(3u, v); b.Increment(3, 2); v = b.Get(3); Assert.AreEqual(2u, v); }
public void BenchmarkBucketsGet() { var buckets = new Buckets(10000, 10); for (uint i = 0; i < buckets.count; i++) { buckets.Get(i % 10000); } }
public void TestBucketsReset() { var b = new Buckets(5, 2); for (uint i = 0; i < 5; i++) { b.Increment(i, 1); } var resetB = b.Reset(); Assert.AreSame(b, resetB, "Returned Buckets should be the same instance"); for (uint i = 0; i < 5; i++) { var c = b.Get(i); Assert.AreEqual(0u, c); } }