コード例 #1
0
    /// <summary>
    /// 读取字节流(完整版)
    /// </summary>
    protected override void toReadBytesFull(BytesReadStream stream)
    {
        stream.startReadObj();

        int booleanDicLen = stream.readLen();

        if (this.booleanDic != null)
        {
            this.booleanDic.clear();
            this.booleanDic.ensureCapacity(booleanDicLen);
        }
        else
        {
            this.booleanDic = new IntBooleanMap(booleanDicLen);
        }

        IntBooleanMap booleanDicT = this.booleanDic;

        for (int booleanDicI = booleanDicLen - 1; booleanDicI >= 0; --booleanDicI)
        {
            int  booleanDicK;
            bool booleanDicV;
            booleanDicK = stream.readInt();

            booleanDicV = stream.readBoolean();

            booleanDicT.put(booleanDicK, booleanDicV);
        }

        int intDicLen = stream.readLen();

        if (this.intDic != null)
        {
            this.intDic.clear();
            this.intDic.ensureCapacity(intDicLen);
        }
        else
        {
            this.intDic = new IntIntMap(intDicLen);
        }

        IntIntMap intDicT = this.intDic;

        for (int intDicI = intDicLen - 1; intDicI >= 0; --intDicI)
        {
            int intDicK;
            int intDicV;
            intDicK = stream.readInt();

            intDicV = stream.readInt();

            intDicT.put(intDicK, intDicV);
        }

        int longDicLen = stream.readLen();

        if (this.longDic != null)
        {
            this.longDic.clear();
            this.longDic.ensureCapacity(longDicLen);
        }
        else
        {
            this.longDic = new IntLongMap(longDicLen);
        }

        IntLongMap longDicT = this.longDic;

        for (int longDicI = longDicLen - 1; longDicI >= 0; --longDicI)
        {
            int  longDicK;
            long longDicV;
            longDicK = stream.readInt();

            longDicV = stream.readLong();

            longDicT.put(longDicK, longDicV);
        }

        int stringDicLen = stream.readLen();

        if (this.stringDic != null)
        {
            this.stringDic.clear();
            this.stringDic.ensureCapacity(stringDicLen);
        }
        else
        {
            this.stringDic = new SMap <string, string>(stringDicLen);
        }

        SMap <string, string> stringDicT = this.stringDic;

        for (int stringDicI = stringDicLen - 1; stringDicI >= 0; --stringDicI)
        {
            string stringDicK;
            string stringDicV;
            stringDicK = stream.readUTF();

            stringDicV = stream.readUTF();

            stringDicT.put(stringDicK, stringDicV);
        }

        stream.endReadObj();
    }
コード例 #2
0
    /// <summary>
    /// 复制(深拷贝)
    /// </summary>
    protected override void toCopy(BaseData data)
    {
        if (!(data is KeepSaveData))
        {
            return;
        }

        KeepSaveData mData = (KeepSaveData)data;

        if (mData.booleanDic != null)
        {
            if (this.booleanDic != null)
            {
                this.booleanDic.clear();
                this.booleanDic.ensureCapacity(mData.booleanDic.size());
            }
            else
            {
                this.booleanDic = new IntBooleanMap(mData.booleanDic.size());
            }

            IntBooleanMap booleanDicT = this.booleanDic;
            if (!mData.booleanDic.isEmpty())
            {
                int    booleanDicKFreeValue = mData.booleanDic.getFreeValue();
                int[]  booleanDicKKeys      = mData.booleanDic.getKeys();
                bool[] booleanDicVValues    = mData.booleanDic.getValues();
                for (int booleanDicKI = booleanDicKKeys.Length - 1; booleanDicKI >= 0; --booleanDicKI)
                {
                    int booleanDicK = booleanDicKKeys[booleanDicKI];
                    if (booleanDicK != booleanDicKFreeValue)
                    {
                        bool booleanDicV = booleanDicVValues[booleanDicKI];
                        int  booleanDicW;
                        bool booleanDicU;
                        booleanDicW = booleanDicK;

                        booleanDicU = booleanDicV;

                        booleanDicT.put(booleanDicW, booleanDicU);
                    }
                }
            }
        }
        else
        {
            this.booleanDic = null;
            nullObjError("booleanDic");
        }

        if (mData.intDic != null)
        {
            if (this.intDic != null)
            {
                this.intDic.clear();
                this.intDic.ensureCapacity(mData.intDic.size());
            }
            else
            {
                this.intDic = new IntIntMap(mData.intDic.size());
            }

            IntIntMap intDicT = this.intDic;
            if (!mData.intDic.isEmpty())
            {
                int   intDicKFreeValue = mData.intDic.getFreeValue();
                int[] intDicKKeys      = mData.intDic.getKeys();
                int[] intDicVValues    = mData.intDic.getValues();
                for (int intDicKI = intDicKKeys.Length - 1; intDicKI >= 0; --intDicKI)
                {
                    int intDicK = intDicKKeys[intDicKI];
                    if (intDicK != intDicKFreeValue)
                    {
                        int intDicV = intDicVValues[intDicKI];
                        int intDicW;
                        int intDicU;
                        intDicW = intDicK;

                        intDicU = intDicV;

                        intDicT.put(intDicW, intDicU);
                    }
                }
            }
        }
        else
        {
            this.intDic = null;
            nullObjError("intDic");
        }

        if (mData.longDic != null)
        {
            if (this.longDic != null)
            {
                this.longDic.clear();
                this.longDic.ensureCapacity(mData.longDic.size());
            }
            else
            {
                this.longDic = new IntLongMap(mData.longDic.size());
            }

            IntLongMap longDicT = this.longDic;
            if (!mData.longDic.isEmpty())
            {
                int    longDicKFreeValue = mData.longDic.getFreeValue();
                int[]  longDicKKeys      = mData.longDic.getKeys();
                long[] longDicVValues    = mData.longDic.getValues();
                for (int longDicKI = longDicKKeys.Length - 1; longDicKI >= 0; --longDicKI)
                {
                    int longDicK = longDicKKeys[longDicKI];
                    if (longDicK != longDicKFreeValue)
                    {
                        long longDicV = longDicVValues[longDicKI];
                        int  longDicW;
                        long longDicU;
                        longDicW = longDicK;

                        longDicU = longDicV;

                        longDicT.put(longDicW, longDicU);
                    }
                }
            }
        }
        else
        {
            this.longDic = null;
            nullObjError("longDic");
        }

        if (mData.stringDic != null)
        {
            if (this.stringDic != null)
            {
                this.stringDic.clear();
                this.stringDic.ensureCapacity(mData.stringDic.size());
            }
            else
            {
                this.stringDic = new SMap <string, string>(mData.stringDic.size());
            }

            SMap <string, string> stringDicT = this.stringDic;
            if (!mData.stringDic.isEmpty())
            {
                string[] stringDicKKeys   = mData.stringDic.getKeys();
                string[] stringDicVValues = mData.stringDic.getValues();
                for (int stringDicKI = stringDicKKeys.Length - 1; stringDicKI >= 0; --stringDicKI)
                {
                    string stringDicK = stringDicKKeys[stringDicKI];
                    if (stringDicK != null)
                    {
                        string stringDicV = stringDicVValues[stringDicKI];
                        string stringDicW;
                        string stringDicU;
                        stringDicW = stringDicK;

                        stringDicU = stringDicV;

                        stringDicT.put(stringDicW, stringDicU);
                    }
                }
            }
        }
        else
        {
            this.stringDic = null;
            nullObjError("stringDic");
        }
    }