Exemplo n.º 1
0
        public StaticBitArray And(StaticBitArray value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }
            if (value.Length != Length)
            {
                throw new ArgumentException(nameof(value));
            }

            for (int i = 0; i < arr.Length; i++)
            {
                arr[i] &= value.arr[i];
            }
            return(this);
        }
Exemplo n.º 2
0
        public static void TestStaticBitArray()
        {
            const int      length = 250;
            StaticBitArray bits   = new StaticBitArray(length);

            bool[] checkAr = new bool[length];


            Console.WriteLine(bits + " " + bits.Length);
            Console.WriteLine(checkAr + " " + checkAr.Length);


            for (int i = 0; i < length; i++)
            {
                bool val = (Rand.Next(2) == 1);
                checkAr[i] = val;
                bits[i]    = val;
            }


            for (int i = 0; i < length; i++)
            {
                Debug.Assert(checkAr[i] == bits[i], $"FAIL, index = {i}");
            }
            Console.WriteLine("[] OK");

            int n = 0;

            foreach (bool bit in bits)
            {
                Debug.Assert(checkAr[n++] == bit, $"FAIL, index = {n}");
            }
            Console.WriteLine("foreach OK");


            bits.Not();
            for (int i = 0; i < length; i++)
            {
                Debug.Assert(checkAr[i] != bits[i], $"FAIL, index = {i}");
            }
        }
Exemplo n.º 3
0
 public Enumerator(StaticBitArray obj)
 {
     this.obj = obj;
 }