Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public FiltersCache(World world)
 {
     this.world = world;
     this.hash  = PoolDictionaryCopyable <int, HashSetCopyable <Entity> > .Spawn(100);
 }