コード例 #1
0
        /// <summary>
        /// Restore a <see cref="ForUtil"/> from a <see cref="DataInput"/>.
        /// </summary>
        internal ForUtil(DataInput @in)
        {
            int packedIntsVersion = @in.ReadVInt32();

            PackedInt32s.CheckVersion(packedIntsVersion);
            encodedSizes = new int[33];
            encoders     = new PackedInt32s.IEncoder[33];
            decoders     = new PackedInt32s.IDecoder[33];
            iterations   = new int[33];

            for (int bpv = 1; bpv <= 32; ++bpv)
            {
                var code         = @in.ReadVInt32();
                var formatId     = (int)((uint)code >> 5);
                var bitsPerValue = (code & 31) + 1;

                PackedInt32s.Format format = PackedInt32s.Format.ById(formatId);
                if (Debugging.AssertsEnabled)
                {
                    Debugging.Assert(format.IsSupported(bitsPerValue));
                }
                encodedSizes[bpv] = EncodedSize(format, packedIntsVersion, bitsPerValue);
                encoders[bpv]     = PackedInt32s.GetEncoder(format, packedIntsVersion, bitsPerValue);
                decoders[bpv]     = PackedInt32s.GetDecoder(format, packedIntsVersion, bitsPerValue);
                iterations[bpv]   = ComputeIterations(decoders[bpv]);
            }
        }