Beispiel #1
0
 /// <summary>
 /// 是否需要清除数组
 /// </summary>
 /// <param name="type">类型</param>
 /// <returns>需要清除数组</returns>
 public static bool IsClearArray(Type type)
 {
     if (type.IsPointer)
     {
         return(false);
     }
     if (type.IsClass || type.IsInterface)
     {
         return(true);
     }
     if (type.IsEnum)
     {
         return(false);
     }
     if (type.IsValueType)
     {
         bool isClear;
         Monitor.Enter(isClearArrayLock);
         try
         {
             if (isClearArrayCache != null)
             {
                 if (isClearArrayCache.TryGetValue(type, out isClear))
                 {
                     return(isClear);
                 }
             }
             else
             {
                 isClearArrayCache = DictionaryCreator <HashType> .Create <bool>();
             }
             isClearArrayCache.Add(type, true);
             isClearArrayCache[type] = isClear = isClearArray(type, isClearArrayCache);
         }
         finally { Monitor.Exit(isClearArrayLock); }
         return(isClear);
     }
     return(true);
 }
Beispiel #2
0
 /// <summary>
 /// 先进先出优先队列
 /// </summary>
 /// <param name="dictionaryCapacity">字典初始化容器尺寸</param>
 public FifoPriorityQueue(int dictionaryCapacity = 0)
 {
     dictionary = dictionaryCapacity <= 0 ? DictionaryCreator <keyType> .Create <Node>() : DictionaryCreator <keyType> .Create <Node>(dictionaryCapacity);
 }