示例#1
0
        public Buckets <int> Run(Buckets <int> buckets)
        {
            var leftValue  = buckets.Get(_leftBucket);
            var rightValue = buckets.Get(_rightBucket);

            return(buckets.Set(_outBucket, leftValue - rightValue));
        }
示例#2
0
        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);
        }
示例#3
0
        public void BenchmarkBucketsSet()
        {
            var buckets = new Buckets(10000, 10);

            for (uint i = 0; i < buckets.count; i++)
            {
                buckets.Set(i % 10000, 1);
            }
        }
示例#4
0
 public Buckets <int> Run(Buckets <int> buckets)
 {
     return(buckets.Set(_bucket, _value));
 }