예제 #1
0
 private static bool Valid(Int64 o) // LUCENENET: CA1822: Mark members as static
 {
     Debugging.Assert(o != null);
     Debugging.Assert(o is Int64);
     Debugging.Assert(o == NO_OUTPUT || o > 0);
     return(true);
 }
예제 #2
0
        public override object Read(DataInput @in)
        {
            long code = @in.ReadVInt64();

            if ((code & 1) == 0)
            {
                // single long
                long v = code.TripleShift(1);
                if (v == 0)
                {
                    return(NO_OUTPUT);
                }
                else
                {
                    return(Int64.GetInstance(v));
                }
            }
            else
            {
                // two longs
                long first  = code.TripleShift(1);
                long second = @in.ReadVInt64();
                return(new TwoInt64s(first, second));
            }
        }
예제 #3
0
        public override object Subtract(object output, object inc)
        {
            if (Debugging.AssertsEnabled)
            {
                Debugging.Assert(Valid(output, false));
                Debugging.Assert(Valid(inc, false));
            }
            Int64 output2 = (Int64)output;
            Int64 inc2    = (Int64)inc;

            if (Debugging.AssertsEnabled)
            {
                Debugging.Assert(output2 >= inc2);
            }

            if (inc2 == NO_OUTPUT)
            {
                return(output2);
            }
            else if (output2.Equals(inc2))
            {
                return(NO_OUTPUT);
            }
            else
            {
                return(Int64.GetInstance(output2 - inc2));
            }
        }
예제 #4
0
        public override object Add(object prefix, object output)
        {
            if (Debugging.AssertsEnabled)
            {
                Debugging.Assert(Valid(prefix, false));
            }
            if (Debugging.AssertsEnabled)
            {
                Debugging.Assert(Valid(output, true));
            }
            Int64 prefix2 = (Int64)prefix;

            if (output is Int64 output2)
            {
                if (prefix2 == NO_OUTPUT)
                {
                    return(output2);
                }
                else if (output2 == NO_OUTPUT)
                {
                    return(prefix2);
                }
                else
                {
                    return(Int64.GetInstance(prefix2 + output2));
                }
            }
            else
            {
                TwoInt64s output3 = (TwoInt64s)output;
                long      v       = prefix2;
                return(new TwoInt64s(output3.First + v, output3.Second + v));
            }
        }
예제 #5
0
        public override object Common(object output1, object output2)
        {
            if (Debugging.AssertsEnabled)
            {
                Debugging.Assert(Valid(output1, false));
                Debugging.Assert(Valid(output2, false));
            }
            Int64 output1_ = (Int64)output1;
            Int64 output2_ = (Int64)output2;

            if (output1_ == NO_OUTPUT || output2_ == NO_OUTPUT)
            {
                return(NO_OUTPUT);
            }
            else if (doShare)
            {
                if (Debugging.AssertsEnabled)
                {
                    Debugging.Assert(output1_ > 0);
                    Debugging.Assert(output2_ > 0);
                }
                return(Int64.GetInstance(Math.Min(output1_, output2_)));
            }
            else if (output1_.Equals(output2_))
            {
                return(output1_);
            }
            else
            {
                return(NO_OUTPUT);
            }
        }