コード例 #1
0
ファイル: ArrayUtils.cs プロジェクト: word-ptr/ecs-submodule
        public static void Copy <TKey, T, TCopy>(DictionaryCopyable <TKey, T> fromDic, ref DictionaryCopyable <TKey, T> dic, TCopy copy) where TCopy : IArrayElementCopy <T>
        {
            if (fromDic == null)
            {
                if (dic != null)
                {
                    foreach (var kv in dic)
                    {
                        copy.Recycle(kv.Value);
                    }

                    PoolDictionaryCopyable <TKey, T> .Recycle(ref dic);
                }

                dic = null;
                return;
            }

            if (dic == null || fromDic.Count != dic.Count)
            {
                if (dic != null)
                {
                    foreach (var kv in dic)
                    {
                        copy.Recycle(kv.Value);
                    }

                    PoolDictionaryCopyable <TKey, T> .Recycle(ref dic);
                }

                dic = PoolDictionaryCopyable <TKey, T> .Spawn(fromDic.Count);
            }

            dic.CopyFrom(fromDic, copy);
        }
コード例 #2
0
ファイル: ArrayUtils.cs プロジェクト: word-ptr/ecs-submodule
        public static void Copy <TKey, T>(DictionaryCopyable <TKey, T> fromDic, ref DictionaryCopyable <TKey, T> dic)
        {
            if (fromDic == null)
            {
                if (dic != null)
                {
                    PoolDictionaryCopyable <TKey, T> .Recycle(ref dic);
                }

                dic = null;
                return;
            }

            if (dic == null || fromDic.Count != dic.Count)
            {
                if (dic != null)
                {
                    PoolDictionaryCopyable <TKey, T> .Recycle(ref dic);
                }

                dic = PoolDictionaryCopyable <TKey, T> .Spawn(fromDic.Count);
            }

            dic.CopyFrom(fromDic);
        }