Beispiel #1
0
        /// <summary>
        ///     Get String representation of bit collection
        /// </summary>
        public string GetString()
        {
            var bitString = "";

            for (var i = 0; i < _bitCollectionLength; i++)
            {
                for (var j = 0; j < _bitArrayLength; j++)
                {
                    bitString += _bitsCollection[i].Get(j) ? "1" : "0";
                }
            }
            return(IntegerBitsetUtils.Reverse(bitString));
        }
Beispiel #2
0
        private static BitArray[] StringToBitCollection(string bitArray)
        {
            var bitCollection = new BitArray[_bitCollectionLength];

            for (var i = 0; i < _bitCollectionLength; i++)
            {
                bitCollection[i] = new BitArray(_bitArrayLength);
            }

            var reverseString = IntegerBitsetUtils.Reverse(bitArray);

            var element = 0;

            for (var i = 0; i < _bitCollectionLength; i++)
            {
                for (var j = 0; j < _bitArrayLength; j++)
                {
                    bitCollection[i].Set(j, reverseString[element] == '1');
                    element++;
                }
            }

            return(bitCollection);
        }
Beispiel #3
0
 /// <summary>
 ///     Get Int32 representation of bit collection
 /// </summary>
 public int GetInt32()
 {
     return(IntegerBitsetUtils.Reverse(GetString()).Select((t, i) => t == '1' ? (int)Math.Pow(2, i) : 0).Sum());
 }