Esempio n. 1
0
        public void MergeUsingUpdate()
        {
            const int count = 32;
            var rand = new Random(2);
            var rs = new RegisterSet(count);
            var rss = new RegisterSet[5];

            for (var i = 0; i < rss.Length; ++i)
            {
                rss[i] = new RegisterSet(count);
                for (uint pos = 0; pos < rs.Count; ++pos)
                {
                    var val = (uint)rand.Next(10);
                    rs.UpdateIfGreater(pos, val);
                    rss[i].Set(pos, val);
                }
            }

            var merged = new RegisterSet(count);
            foreach (var t in rss)
            {
                for (uint pos = 0; pos < rs.Count; pos++)
                {
                    merged.UpdateIfGreater(pos, t.Get(pos));
                }
            }

            for (uint pos = 0; pos < rs.Count; pos++)
                Assert.That(merged.Get(pos), Is.EqualTo(rs.Get(pos)));
        }
Esempio n. 2
0
 public void GetAndSet_AllPositions()
 {
     var rs = new RegisterSet(Pow(2, 4));
     for (uint i = 0; i < Pow(2, 4); ++i)
     {
         rs.Set(i, i % 31);
         Assert.That(rs.Get(i), Is.EqualTo(i % 31));
     }
 }
Esempio n. 3
0
 public void Merge(RegisterSet other)
 {
     for (var bucket = 0; bucket < M.Length; ++bucket)
     {
         uint word = 0;
         for (var j = 0; j < Log2BitsPerWord; ++j)
         {
             uint mask = 0x1Fu << (RegisterSize * j);
             uint thisVal = M[bucket] & mask;
             uint otherVal = other.M[bucket] & mask;
             word |= (thisVal < otherVal) ? otherVal : thisVal;
         }
         M[bucket] = word;
     }
 }
Esempio n. 4
0
 public void Merge(RegisterSet other)
 {
     for (var bucket = 0; bucket < M.Length; ++bucket)
     {
         uint word = 0;
         for (var j = 0; j < Log2BitsPerWord; ++j)
         {
             uint mask     = 0x1Fu << (RegisterSize * j);
             uint thisVal  = M[bucket] & mask;
             uint otherVal = other.M[bucket] & mask;
             word |= (thisVal < otherVal) ? otherVal : thisVal;
         }
         M[bucket] = word;
     }
 }
Esempio n. 5
0
 public void GetAndSet_WithSmallBits()
 {
     var rs = new RegisterSet(6);
     rs.Set(0, 11);
     Assert.That(rs.Get(0), Is.EqualTo(11));
 }
Esempio n. 6
0
 public void GetAndSet()
 {
     var rs = new RegisterSet(Pow(2, 4));
     rs.Set(0, 11);
     Assert.That(rs.Get(0), Is.EqualTo(11));
 }