Ejemplo n.º 1
0
        public BitSequence Clone()
        {
            BitSequence clone = new BitSequence(data.Length);

            clone.size = size;
            Array.Copy(data, clone.data, clone.data.Length);
            return(clone);
        }
Ejemplo n.º 2
0
        public override bool Equals(object obj)
        {
            BitSequence other = obj as BitSequence;

            if (other == null || size != other.size)
            {
                return(false);
            }

            for (int n = 0; n < size; n++)
            {
                if (this[n] != other[n])
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 3
0
        public static BitSequence FromString(string bitString)
        {
            Guard.IsNotNull(bitString, nameof(bitString));
            BitSequence sequence = new BitSequence(bitString.Length / 8 + 1);

            for (int n = 0; n < bitString.Length; n++)
            {
                switch (bitString[n])
                {
                case '0': sequence[n] = Bit.Zero; break;

                case '1': sequence[n] = Bit.One; break;

                default: throw new ArgumentException();
                }
            }
            return(sequence);
        }