Пример #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);
        }
Пример #3
0
 internal Enumerator(DictionaryInt <TValue> dictionary)
 {
     this.dictionary   = dictionary;
     this.version      = dictionary.version;
     this.index        = 0;
     this.currentValue = default(TValue);
 }
Пример #4
0
 public KeyCollection(DictionaryInt <TValue> dictionary)
 {
     if (dictionary == null)
     {
         ThrowHelper.ThrowArgumentNullException(ExceptionArgument.dictionary);
     }
     this.dictionary = dictionary;
 }
Пример #5
0
 internal Enumerator(DictionaryInt <TValue> dictionary, int getEnumeratorRetType)
 {
     this.dictionary           = dictionary;
     this.version              = dictionary.version;
     this.index                = 0;
     this.getEnumeratorRetType = getEnumeratorRetType;
     this.current              = new KeyValuePair <TKey, TValue>();
 }
Пример #6
0
        public static void Recycle <T, TCopy>(ref DictionaryInt <T> list, TCopy copy) where TCopy : IArrayElementCopy <T>
        {
            if (list != null)
            {
                foreach (var item in list)
                {
                    copy.Recycle(item.Value);
                }

                PoolDictionaryInt <T> .Recycle(ref list);
            }
        }
Пример #7
0
    public static void test()
    {
        DictionaryInt <string> dic_str = new DictionaryInt <string>();

        dic_str.Add(1, "ok1");
        dic_str.Add(10, "ok10");
        dic_str.Add(100, "ok100");

        string v = dic_str[1];

        Debug.LogError("v " + v);

        v = dic_str[10];
        Debug.LogError("v " + v);

        v = dic_str[100];
        Debug.LogError("v " + v);

        bool isexist = dic_str.ContainsKey(1);

        Debug.LogError("isexist " + isexist);

        isexist = dic_str.ContainsKey(2);
        Debug.LogError("isexist " + isexist);

        isexist = dic_str.ContainsKey(100);
        Debug.LogError("isexist " + isexist);

        bool is_remove = dic_str.Remove(10);

        Debug.LogError("is remove " + is_remove);

        isexist = dic_str.ContainsKey(10);
        Debug.LogError("isexist " + isexist);

        dic_str[99] = "ok99";
        Debug.LogError(dic_str[99]);
    }
Пример #8
0
 public static void Recycle(ref DictionaryInt <TValue> dic)
 {
     Pools.current.PoolRecycle(ref dic);
 }