BitsetsNET.RoaringBitset.Flip C# (CSharp) Method

Flip() public method

If the given index is not in the set add it, otherwise remove it.
public Flip ( int x ) : void
x int
return void
        public void Flip(int x)
        {
            ushort hb = Utility.GetHighBits(x);
            int i = containers.GetIndex(hb);

            if (i >= 0)
            {
                Container c = containers.GetContainerAtIndex(i).Flip(Utility.GetLowBits(x));
                if (c.GetCardinality() > 0)
                {
                    containers.SetContainerAtIndex(i, c);
                }
                else
                {
                    containers.RemoveAtIndex(i);
                }
            }
            else
            {
                ArrayContainer newac = new ArrayContainer();
                containers.InsertNewKeyValueAt(-i - 1, hb, newac.Add(Utility.GetLowBits(x)));
            }
        }

Same methods

RoaringBitset::Flip ( int start, int end ) : void