natix.CompactDS.DoublingSearchCoding64.Encode C# (CSharp) Method

Encode() public method

public Encode ( BitStream32 stream, long u ) : void
stream BitStream32
u long
return void
        public void Encode(BitStream32 stream, long u)
        {
            long check;
            long min = 0;
            int galloping = 1;
            while (true) {
                check = (1L << galloping) - 1L;
                if (u > check) {
                    stream.Write (true);
                    min = check + 1L;
                    ++galloping;
                } else {
                    stream.Write (false);
                    if (min == 0L) {
                        this.SecondCoding.Encode (stream, u, 2);
                    } else {
                        this.SecondCoding.Encode (stream, u - min, min);
                    }
                    break;
                }
            }
        }