Exemplo n.º 1
0
        private bool TryMerge(Support.BitSet bs1, Support.BitSet bs2)
        {
            if (bs1.BitCount != bs2.BitCount)
            {
                return(false);
            }

            UInt32 actorNum = bs1.BitCount / 2;

            for (UInt32 i = 0; i < actorNum; i++)
            {
                int b1 = bs1.IsBit(i * 2) ? 1 : 0;
                int b2 = bs1.IsBit(i * 2 + 1) ? 1 : 0;
                int v1 = b1 | (b2 << 1);

                b1 = bs2.IsBit(i * 2) ? 1 : 0;
                b2 = bs2.IsBit(i * 2 + 1) ? 1 : 0;
                int v2 = b1 | (b2 << 1);

                if (v1 == 0 && v2 != 0)
                {
                    return(false);
                }
                if (v2 == 0 && v1 != 0)
                {
                    return(false);
                }
                if (v1 < v2)
                {
                    bs1.SetBit(i * 2, b1 == 0 ? false : true);
                    bs1.SetBit(i * 2 + 1, b2 == 0 ? false : true);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        protected static Support.BitSet WriteSaveFields(ISerializer obj, TypeDescGenerator.TypeDesc tDesc, IWriter pkg)
        {
            var bitSet = new Support.BitSet();

            bitSet.Init((UInt16)tDesc.Members.Count);
            for (int i = 0; i < tDesc.Members.Count; i++)
            {
                bool cmp = tDesc.IsDefaultValue(obj, tDesc.Members[i].PropInfo);
                if (cmp == false)
                {
                    bitSet.SetBit((UInt32)i, true);
                }
            }
            var byteArray = TypeDescGenerator.Instance.GetSerializer(typeof(byte[]));

            byteArray.WriteValue(bitSet.Data, pkg);
            return(bitSet);
        }
Exemplo n.º 3
0
 public void SetBit(EBitDefine bit, bool value)
 {
     BitSet.SetBit((int)bit, value);
 }