Esempio n. 1
0
        /// <summary>
        /// 移除匹配值
        /// </summary>
        /// <param name="list">单向动态数组</param>
        /// <param name="isValue">数据匹配器</param>
        /// <returns>单向动态数组</returns>
        public unsafe static list </*Type[0]*/ ulong /*Type[0]*/> remove
            (this list </*Type[0]*/ ulong /*Type[0]*/> list, func </*Type[0]*/ ulong /*Type[0]*/, bool> isValue)
        {
            int count = list.count();

            if (count != 0)
            {
                if (isValue == null)
                {
                    log.Default.Throw(log.exceptionType.Null);
                    fixed(/*Type[0]*/ ulong /*Type[0]*/ *valueFixed = list.Unsafer.Array)
                    {
                        /*Type[0]*/
                        ulong /*Type[0]*/ *start = valueFixed, end = valueFixed + count;

                        while (start != end && !isValue(*start))
                        {
                            ++start;
                        }
                        /*Type[0]*/
                        ulong /*Type[0]*/ *write = start;

                        while (start != end)
                        {
                            if (!isValue(*start))
                            {
                                *write++ = *start;
                            }
                            ++start;
                        }
                        list.Unsafer.AddLength((int)(write - valueFixed) - count);
                    }
            }
            return(list);
        }
Esempio n. 2
0
 /// <summary>
 /// 范围排序
 /// </summary>
 /// <param name="list">待排序单向动态数组</param>
 /// <param name="skipCount">跳过记录数</param>
 /// <param name="getCount">获取记录数,小于0表示所有</param>
 /// <returns>排序范围数组</returns>
 public static collection </*Type[0]*/ ulong /*Type[0]*/> getRangeSort/*Compare[0]*//*Compare[0]*/
     (this list </*Type[0]*/ ulong /*Type[0]*/> list, int skipCount, int getCount)
 {
     if (list.count() != 0)
     {
         return(algorithm.quickSort.GetRangeSort/*Compare[0]*//*Compare[0]*/ (list.Unsafer.Array, 0, list.Count, skipCount, getCount));
     }
     return(null);
 }
Esempio n. 3
0
 /// <summary>
 /// 范围排序
 /// </summary>
 /// <typeparam name="valueType">数据类型</typeparam>
 /// <param name="list">待排序单向动态数组</param>
 /// <param name="getKey">排序键</param>
 /// <param name="skipCount">跳过记录数</param>
 /// <param name="getCount">获取记录数,小于0表示所有</param>
 /// <returns>排序范围数组</returns>
 public static valueType[] getRangeSort/*Compare[0]*//*Compare[0]*/ <valueType>
     (this list <valueType> list, func <valueType, /*Type[0]*/ ulong /*Type[0]*/> getKey, int skipCount, int getCount)
 {
     if (list.count() != 0)
     {
         return(algorithm.quickSort.GetRangeSort/*Compare[0]*//*Compare[0]*/
                    (list.Unsafer.Array, 0, list.Count, getKey, skipCount, getCount));
     }
     return(nullValue <valueType> .Array);
 }
Esempio n. 4
0
 /// <summary>
 /// 范围排序
 /// </summary>
 /// <param name="list">待排序单向动态数组</param>
 /// <param name="startIndex">起始位置</param>
 /// <param name="count">结束位置</param>
 /// <param name="skipCount">跳过记录数</param>
 /// <param name="getCount">获取记录数</param>
 /// <returns>排序范围数组</returns>
 public static collection </*Type[0]*/ ulong /*Type[0]*/> getRangeSort/*Compare[0]*//*Compare[0]*/
     (this list </*Type[0]*/ ulong /*Type[0]*/> list, int startIndex, int count, int skipCount, int getCount)
 {
     array.range range = new array.range(list.count(), startIndex, count);
     if ((count = range.GetCount) != 0)
     {
         return(algorithm.quickSort.GetRangeSort/*Compare[0]*//*Compare[0]*/
                    (list.Unsafer.Array, range.SkipCount, count, skipCount, getCount));
     }
     return(null);
 }
Esempio n. 5
0
        /// <summary>
        /// 分页排序
        /// </summary>
        /// <param name="list">待排序单向动态数组</param>
        /// <param name="pageSize">分页尺寸</param>
        /// <param name="currentPage">页号</param>
        /// <returns>分页排序数据</returns>
        public static collection </*Type[0]*/ ulong /*Type[0]*/> getPageSort/*Compare[0]*//*Compare[0]*/
            (this list </*Type[0]*/ ulong /*Type[0]*/> list, int pageSize, int currentPage)
        {
            array.page page  = new array.page(list.count(), pageSize, currentPage);
            int        count = page.CurrentPageSize;

            if (count != 0)
            {
                return(algorithm.quickSort.GetRangeSort/*Compare[0]*//*Compare[0]*/ (list.Unsafer.Array, page.SkipCount, count));
            }
            return(null);
        }
Esempio n. 6
0
 /// <summary>
 /// 范围排序
 /// </summary>
 /// <typeparam name="valueType">数据类型</typeparam>
 /// <param name="list">待排序单向动态数组</param>
 /// <param name="startIndex">起始位置</param>
 /// <param name="count">结束位置</param>
 /// <param name="getKey">排序键</param>
 /// <param name="skipCount">跳过记录数</param>
 /// <param name="getCount">获取记录数</param>
 /// <returns>排序范围数组</returns>
 public static valueType[] getRangeSort/*Compare[0]*//*Compare[0]*/ <valueType>
     (this list <valueType> list, int startIndex, int count, func <valueType, /*Type[0]*/ ulong /*Type[0]*/> getKey
     , int skipCount, int getCount)
 {
     array.range range = new array.range(list.count(), startIndex, count);
     if ((count = range.GetCount) != 0)
     {
         return(algorithm.quickSort.GetRangeSort/*Compare[0]*//*Compare[0]*/
                    (list.Unsafer.Array, range.SkipCount, count, getKey, skipCount, getCount));
     }
     return(nullValue <valueType> .Array);
 }
Esempio n. 7
0
        /// <summary>
        /// 唯一静态哈希字典
        /// </summary>
        /// <param name="values">数据集合</param>
        /// <param name="size">哈希容器尺寸</param>
        public uniqueDictionary(list <keyValue <keyType, valueType> > values, int size)
        {
            int count = values.count();

            if (count > size || size <= 0)
            {
                log.Error.Throw(log.exceptionType.IndexOutOfRange);
            }
            array = new keyValue <keyType, valueType> [size];
            if (count != 0)
            {
                fromArray(values.array, count, size);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 移除数据
        /// </summary>
        /// <param name="list">单向动态数组</param>
        /// <param name="index">数据位置</param>
        /// <returns>单向动态数组</returns>
        public static list </*Type[0]*/ ulong /*Type[0]*/> removeAt(this list </*Type[0]*/ ulong /*Type[0]*/> list, int index)
        {
            int count = list.count();

            if ((uint)index < (uint)count)
            {
                unsafer.array.Move(list.Unsafer.Array, index + 1, index, --count - index);
                list.Unsafer.AddLength(-1);
            }
            else
            {
                log.Default.Throw(log.exceptionType.IndexOutOfRange);
            }
            return(list);
        }
Esempio n. 9
0
        /// <summary>
        /// 移除数据范围
        /// </summary>
        /// <param name="list">单向动态数组</param>
        /// <param name="index">起始位置</param>
        /// <param name="count">移除数量</param>
        /// <returns>单向动态数组</returns>
        public static list </*Type[0]*/ ulong /*Type[0]*/> removeRange(this list </*Type[0]*/ ulong /*Type[0]*/> list, int index, int count)
        {
            int valueCount = list.count();

            if (index + count <= valueCount && index >= 0 && count >= 0 && list != null)
            {
                list.Unsafer.AddLength(-count);
                unsafer.array.Move(list.Unsafer.Array, index + count, index, list.Count - index);
            }
            else
            {
                log.Default.Throw(log.exceptionType.IndexOutOfRange);
            }
            return(list);
        }
Esempio n. 10
0
        /// <summary>
        /// 移除数据
        /// </summary>
        /// <param name="list">单向动态数组</param>
        /// <param name="index">数据位置</param>
        /// <returns>被移除的数据</returns>
        public static /*Type[0]*/ ulong /*Type[0]*/ getRemoveAt(this list </*Type[0]*/ ulong /*Type[0]*/> list, int index)
        {
            int count = list.count();

            if ((uint)index < (uint)count)
            {
                list </*Type[0]*/ ulong /*Type[0]*/> .unsafer values = new list </*Type[0]*/ ulong /*Type[0]*/> .unsafer {
                    List = list
                };
                /*Type[0]*/
                ulong /*Type[0]*/ value = values.Array[index];
                unsafer.array.Move(values.Array, index + 1, index, --count - index);
                values.AddLength(-1);
                return(value);
            }
            log.Default.Throw(log.exceptionType.IndexOutOfRange);
            return(default(/*Type[0]*/ ulong /*Type[0]*/));
        }
Esempio n. 11
0
 /// <summary>
 /// 获取匹配数据位置
 /// </summary>
 /// <param name="list">单向动态数组</param>
 /// <param name="isValue">数据匹配器</param>
 /// <returns>匹配位置,失败为-1</returns>
 public unsafe static int indexOf(this list </*Type[0]*/ ulong /*Type[0]*/> list, func </*Type[0]*/ ulong /*Type[0]*/, bool> isValue)
 {
     return(list.count() != 0 ? list.Unsafer.Array.indexOf(0, list.Count, isValue) : -1);
 }
Esempio n. 12
0
 /// <summary>
 /// 取子集合
 /// </summary>
 /// <typeparam name="valueType">数据类型</typeparam>
 /// <param name="list">单向动态数组</param>
 /// <param name="startIndex">起始位置</param>
 /// <param name="count">子集合数据数量</param>
 /// <param name="getVlaue">数据获取器</param>
 /// <returns>子集合</returns>
 public unsafe static valueType[] getSub <valueType>
     (this list </*Type[0]*/ ulong /*Type[0]*/> list, int startIndex, int count, func </*Type[0]*/ ulong /*Type[0]*/, valueType> getVlaue)
 {
     array.range range = new array.range(list.count(), startIndex, count);
     return((count = range.GetCount) != 0 ? list.Unsafer.Array.getSub(range.SkipCount, count, getVlaue) : nullValue <valueType> .Array);
 }
Esempio n. 13
0
 /// <summary>
 /// 连接字符串
 /// </summary>
 /// <param name="list">数据集合</param>
 /// <returns>字符串</returns>
 public static string[] getString(this list </*Type[0]*/ ulong /*Type[0]*/> list)
 {
     return(list.count() != 0 ? list.Unsafer.Array.getString(0, list.Count) : nullValue <string> .Array);
 }