Пример #1
0
 /// <summary>
 /// Creates an empty binary matrix.
 /// </summary>
 public BinaryMatrix3D()
 {
     for (int i = 0; i < 8; i++)
     {
         _Matrix[i] = new BinaryArrayInLong();
     }
 }
Пример #2
0
 /// <summary>
 /// Creates an empty binary matrix.
 /// </summary>
 public BinaryMatrix3D()
 {
     for (int i = 0; i < 8; i++)
      {
     _Matrix[i] = new BinaryArrayInLong();
      }
 }
Пример #3
0
        public void ItemTest()
        {
            BinaryArrayInLong target = new BinaryArrayInLong();
             Random r = new Random();

             for (int pass = 1; pass < 4; pass++)
             {
            bool[] expected = new bool[64];

            for (int i = 0; i < 64; i++)
            {
               expected[i] = (r.Next(2) == 1);
               target[i] = expected[i];
            }

            // read the values and compare with the expected
            for (int i = 0; i < 64; i++)
            {
               bool received = target[i];
               Assert.IsTrue(received == expected[i], "Stored data do not match at index " + i + "; pass: "******"; received: " + received.ToString() + "; expected: " + expected[i]);
            }
             }
        }
Пример #4
0
        public void BinaryArrayInULongConstructorTest()
        {
            BinaryArrayInLong target = new BinaryArrayInLong();
             long received = target.GetValue();
             Assert.IsTrue(received == 0, "Expected 0 but received " + received);

             target = new BinaryArrayInLong(new bool[] { true, false, true, false, true, false, true, false, true, false, true, false });
             received = target.GetValue();
             Assert.IsTrue(received == 1365, "Expected 1365 but received " + received);

             target = new BinaryArrayInLong(new bool[] { false, true, false, true, false, true, false, true, false, true, false, true });
             received = target.GetValue();
             Assert.IsTrue(received == 2730, "Expected 2730 but received " + received);

             bool[] allTrue = new bool[64];
             for (int i = 0; i < 64; i++)
             {
            allTrue[i] = true;
             }
             target = new BinaryArrayInLong(allTrue);
             received = target.GetValue();
             Assert.IsTrue(received == -1, "Expected -1 but received " + received);
        }
Пример #5
0
        /// <summary>
        /// Updates the array with new data.
        /// </summary>
        /// <param name="newData">New data array</param>
        public void UpdateMatrix(bool[][][] newData)
        {
            Reset();

            for (int x = 0; x < 8; x++)
            {
                bool[] array = new bool[64];

                for (int y = 0; y < 8; y++)
                {
                    for (int z = 0; z < 8; z++)
                    {
                        if (newData[x][y][z])
                        {
                            byte position = CalculatePosition(ref y, ref z);
                            array[position] = true;
                        }
                    }
                }

                _Matrix[x] = new BinaryArrayInLong(array);
            }
        }
Пример #6
0
        /// <summary>
        /// Updates the array with new data.
        /// </summary>
        /// <param name="newData">New data array</param>
        public void UpdateMatrix(bool[][][] newData)
        {
            Reset();

             for (int x = 0; x < 8; x++)
             {
            bool[] array = new bool[64];

            for (int y = 0; y < 8; y++)
            {
               for (int z = 0; z < 8; z++)
               {
                  if (newData[x][y][z])
                  {
                     byte position = CalculatePosition(ref y, ref z);
                     array[position] = true;
                  }
               }
            }

            _Matrix[x] = new BinaryArrayInLong(array);
             }
        }