예제 #1
0
        public static void Copy <T, TCopy>(DictionaryInt <T> fromDic, ref DictionaryInt <T> dic, TCopy copy) where TCopy : IArrayElementCopy <T>
        {
            if (fromDic == null)
            {
                if (dic != null)
                {
                    foreach (var kv in dic)
                    {
                        copy.Recycle(kv.Value);
                    }

                    PoolDictionaryInt <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);
                    }

                    PoolDictionaryInt <T> .Recycle(ref dic);
                }

                dic = PoolDictionaryInt <T> .Spawn(fromDic.Count);
            }

            dic.CopyFrom(fromDic, copy);
        }
예제 #2
0
        public static void Copy <T>(DictionaryInt <T> fromDic, ref DictionaryInt <T> dic)
        {
            if (fromDic == null)
            {
                if (dic != null)
                {
                    PoolDictionaryInt <T> .Recycle(ref dic);
                }

                dic = null;
                return;
            }

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

                dic = PoolDictionaryInt <T> .Spawn(fromDic.Count);
            }

            dic.CopyFrom(fromDic);
        }