예제 #1
0
        /// <summary>
        /// 获取匹配数组
        /// </summary>
        /// <param name="array">数组数据</param>
        /// <param name="isValue">数据匹配器</param>
        /// <returns>匹配数组</returns>
        public static /*Type[0]*/ ulong /*Type[0]*/[] getFindArray(this SubArray </*Type[0]*/ ulong /*Type[0]*/> array, Func </*Type[0]*/ ulong /*Type[0]*/, bool> isValue)
        {
            if (array.Length == 0)
            {
                return(NullValue </*Type[0]*/ ulong /*Type[0]*/> .Array);
            }
            int           length = ((array.Length + 63) >> 6) << 3;
            UnmanagedPool pool   = UnmanagedPool.GetDefaultPool(length);

            Pointer.Size data = pool.GetSize64(length);
            try
            {
                Memory.ClearUnsafe(data.ULong, length >> 3);
                return(FixedArray.GetFindArray(array.Array, array.Start, array.Length, isValue, new MemoryMap(data.Data)));
            }
            finally { pool.PushOnly(ref data); }
        }
예제 #2
0
        /// <summary>
        /// 获取匹配数组
        /// </summary>
        /// <typeparam name="valueType">数据类型</typeparam>
        /// <param name="array">数组数据</param>
        /// <param name="isValue">数据匹配器</param>
        /// <returns>匹配数组</returns>
        public unsafe static valueType[] getFindArray <valueType>(this valueType[] array, Func <valueType, bool> isValue)
        {
            int length = array.length();

            if (length == 0)
            {
                return(NullValue <valueType> .Array);
            }
            UnmanagedPool pool = AutoCSer.UnmanagedPool.GetDefaultPool(length = ((length + 63) >> 6) << 3);

            Pointer.Size buffer = pool.GetSize64(length);
            try
            {
                Memory.ClearUnsafe(buffer.ULong, length >> 3);
                return(getFindArray(array, isValue, new MemoryMap(buffer.Data)));
            }
            finally { pool.PushOnly(ref buffer); }
        }
예제 #3
0
 /// <summary>
 /// 静态哈希字典
 /// </summary>
 /// <param name="values">初始化键值对集合</param>
 public unsafe StaticDictionary(KeyValue <keyType, valueType>[] values)
 {
     if (values.isEmpty())
     {
         indexs = defaultIndexs;
         array  = NullValue <KeyValue <keyType, valueType> > .Array;
     }
     else
     {
         int           length = ((values.Length + 1) >> 1) * (sizeof(int) * 2);
         UnmanagedPool pool   = fastCSharp.UnmanagedPool.GetDefaultPool(length);
         Pointer.Size  data   = pool.GetSize64(length);
         try
         {
             getValues(values, data.Int);
         }
         finally { pool.PushOnly(ref data); }
     }
 }