public void Bitfield_Clear_IsCorrect()
        {
            var bitfield = new Bitfield();

            bitfield.Set(3);
            Assert.Equal("EA==", bitfield.GetBase64());
            bitfield.Clear(3);
            bitfield.Set(8);
            Assert.Equal("AIA=", bitfield.GetBase64());
        }
Exemplo n.º 2
0
        public IEnumerable <Bitfield> Order(Bitfield other)
        {
            int lowest  = Int32.MaxValue;
            int highest = Int32.MinValue;
            int maximum = buffer.Length;

            if (other.Length < maximum)
            {
                maximum = other.Maximum;
            }

            for (int i = other.Minimum; i < maximum; i++)
            {
                if (other[i])
                {
                    if (lowest > available[i])
                    {
                        lowest = available[i];
                    }

                    if (highest < available[i])
                    {
                        highest = available[i];
                    }
                }
            }

            if (highest > 0)
            {
                for (int i = lowest; i <= highest; i++)
                {
                    buffer.Clear();

                    for (int j = other.Minimum; j <= other.Maximum; j++)
                    {
                        if (other[j] && available[j] == i)
                        {
                            buffer[j] = true;
                        }
                    }

                    if (buffer.Completed > 0)
                    {
                        yield return(buffer);
                    }
                }
            }
        }