static void Main(string[] args)
        {
            BitArray64 number1 = new BitArray64(7);
            BitArray64 number2 = new BitArray64(7);

            Console.WriteLine(number1);

            //Test indexer
            Console.WriteLine(number1[0]);
            number1[3] = 1;

            //Test Equals
            Console.WriteLine(number1 == number2);

            //Test "=="
            Console.WriteLine(number1.Equals(number2));

            //Test enumerator
            foreach (var item in number1)
            {
                Console.Write(item);
            }
            Console.WriteLine();
            //Test GetHashCode
            Console.WriteLine(number1.GetHashCode());
            Console.WriteLine(number2.GetHashCode());
        }
Example #2
0
        static void Main(string[] args)
        {
            BitArray64 array        = new BitArray64(123456789);
            BitArray64 anotherArray = new BitArray64(2343513153);
            BitArray64 thirdArray   = new BitArray64(123456789);

            Console.WriteLine("Check the Equals method.");
            Console.WriteLine("The arrays are not equal so it should return false");
            Console.WriteLine(array.Equals(anotherArray));
            Console.WriteLine();
            Console.WriteLine("Check the == operator.");
            Console.WriteLine("The arrays are equal so it should return true");
            Console.WriteLine(array == thirdArray);
            Console.WriteLine();
            Console.WriteLine("Testing the index.");
            Console.WriteLine("Printing the 3 - rd element of the first array. It is 3");
            Console.WriteLine(array[2].ToString());
            Console.WriteLine();
            Console.WriteLine("The unique hash codes of the three arays are :");
            Console.WriteLine(array.GetHashCode().ToString());
            Console.WriteLine(anotherArray.GetHashCode().ToString());
            Console.WriteLine(thirdArray.GetHashCode().ToString());
            Console.WriteLine();
            Console.WriteLine("Printing the third array sequence and testing the foreach loop. ");
            foreach (var digit in thirdArray)
            {
                Console.Write("{0} ", digit.ToString());
            }
            Console.WriteLine();
        }
Example #3
0
        private static void Main()
        {
            var bitArray = new BitArray64(4611686018427387904);

            Console.WriteLine("Original bitarray:");

            Console.WriteLine(bitArray);

            Console.WriteLine("Changed first bit to 1:");
            bitArray[0] = 1;
            Console.WriteLine(bitArray);

            Console.WriteLine("Summing the bits in the bitarray with foreach:");

            int sum = 0;

            foreach (var bit in bitArray)
            {
                sum += bit;
            }
            Console.WriteLine(sum);

            var bitArray2 = new BitArray64(4611686018427387904);

            Console.WriteLine("Comparing the original bitarray with the modified one: ");
            Console.WriteLine("Are they equal? " + (bitArray2 == bitArray));
        }
Example #4
0
        static void Main(string[] args)
        {
            var arr = new BitArray64(4);

            arr[2] = 123424143;

            foreach (var item in arr)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine(arr.GetHashCode());
        }
        public static void Main()
        {
            var bitArr        = new BitArray64(5);
            var anotherBitArr = new BitArray64(5);

            // printing first bit array to check if the ToString() method works correctly
            Console.WriteLine(bitArr);
            Console.WriteLine("-----------");

            // testing the two operators for comaprison == and != for both result cases
            // when the two arrays are equal and when they are not
            Console.WriteLine(bitArr == anotherBitArr);
            Console.WriteLine(bitArr != anotherBitArr);
            anotherBitArr[1] = 1;

            // changing the bit at first position of one of the bit array and comparing the again
            Console.WriteLine(bitArr == anotherBitArr);
            Console.WriteLine(bitArr != anotherBitArr);

            // checking the GetHashCode() method
            Console.WriteLine(bitArr.GetHashCode());
            Console.WriteLine(anotherBitArr.GetHashCode());

            Console.WriteLine("First bit array decimal value: {0}", bitArr.BitsValue);
            Console.WriteLine("Second bit array decimal value: {0}", anotherBitArr.BitsValue);

            // setting all bits from 31 to 40 to 1 and then
            // printing every bit from the first bit array using foreach

            for (int i = 31; i <= 40; i++)
            {
                bitArr[i] = 1;
            }

            int counter = 63;

            foreach (var bit in bitArr)
            {
                Console.WriteLine("Bit position: {0} -> Bit value: {1}", counter, bit);
                counter--;
            }
        }
Example #6
0
 public static bool operator !=(BitArray64 first, BitArray64 second)
 {
     return(!BitArray64.Equals(first, second));
 }
Example #7
0
 public static bool operator ==(BitArray64 firstArr, BitArray64 secondArr)
 {
     return(BitArray64.Equals(firstArr, secondArr));
 }