Example #1
0
        /// <summary>
        /// 获取匹配分页集合
        /// </summary>
        /// <param name="pageSize">分页长度</param>
        /// <param name="currentPage">当前页号</param>
        /// <param name="isValue">数据匹配器</param>
        /// <param name="count">匹配数据总数</param>
        /// <returns>匹配分页集合</returns>
        internal list <valueType> GetArrayPage(int pageSize, int currentPage, func <valueType, bool> isValue, out int count)
        {
            int valueCount = 0;

            array.page page            = new array.page(Array.Length, pageSize, currentPage);
            int        currentPageSize = page.CurrentPageSize;

            list <valueType> .unsafer values = new list <valueType>(page.CurrentPageSize).Unsafer;
            int skipCount = page.SkipCount;

            currentPageSize += skipCount;
            foreach (valueType value in Array)
            {
                if (isValue(value))
                {
                    if (valueCount >= skipCount && valueCount < currentPageSize)
                    {
                        values.Add(value);
                    }
                    ++valueCount;
                }
            }
            count = valueCount;
            return(values.List);
        }
Example #2
0
 /// <summary>
 /// 获取分页记录集合
 /// </summary>
 /// <typeparam name="arrayType"></typeparam>
 /// <param name="getValue">数组转换</param>
 /// <param name="pageSize">分页长度</param>
 /// <param name="currentPage">分页页号</param>
 /// <param name="count">记录总数</param>
 /// <returns></returns>
 public arrayType[] GetPageDesc <arrayType>(Func <valueType, arrayType> getValue, int pageSize, int currentPage, out int count)
 {
     if (getValue == null)
     {
         fastCSharp.log.Default.Throw(fastCSharp.log.exceptionType.Null);
     }
     Monitor.Enter(SqlTool.Lock);
     try
     {
         array.page  page       = new array.page(count = Count, pageSize, currentPage);
         arrayType[] values     = new arrayType[page.CurrentPageSize];
         int         startIndex = this.getIndex(Count - page.SkipCount - page.CurrentPageSize);
         for (int writeIndex = values.Length, index = startIndex; writeIndex != 0; ++index)
         {
             valueType value = this.values[index];
             while (value == null)
             {
                 value = this.values[++index];
             }
             values[--writeIndex] = getValue(value);
         }
         return(values);
     }
     finally { Monitor.Exit(SqlTool.Lock); }
 }
Example #3
0
        /// <summary>
        /// 分页排序
        /// </summary>
        /// <param name="array">数组子串</param>
        /// <param name="pageSize">分页尺寸</param>
        /// <param name="currentPage">页号</param>
        /// <returns>分页排序数据</returns>
        public static subArray </*Type[0]*/ ulong /*Type[0]*/> getPageSort/*Compare[0]*//*Compare[0]*/
            (this subArray </*Type[0]*/ ulong /*Type[0]*/> array, int pageSize, int currentPage)
        {
            array.page page     = new array.page(array.Count, pageSize, currentPage);
            int        getCount = page.CurrentPageSize;

            if (getCount != 0)
            {
                return(fastCSharp.algorithm.quickSort.GetRangeSort/*Compare[0]*//*Compare[0]*/ (array.UnsafeArray, array.StartIndex, array.Count, page.SkipCount, getCount));
            }
            return(default(subArray </*Type[0]*/ ulong /*Type[0]*/>));
        }
Example #4
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);
        }
Example #5
0
 /// <summary>
 /// 获取分页数据集合
 /// </summary>
 /// <param name="pageSize">分页大小</param>
 /// <param name="currentPage">分页页号</param>
 /// <param name="count">数据总数</param>
 /// <returns>分页数据集合</returns>
 public valueType[] GetPage(int pageSize, int currentPage, out int count)
 {
     valueType[] values = null;
     count = 0;
     Monitor.Enter(cache.SqlTool.Lock);
     try
     {
         array.page page = new array.page(count = tree.Count, pageSize, currentPage);
         values = tree.GetRange(page.SkipCount, page.CurrentPageSize);
     }
     finally { Monitor.Exit(cache.SqlTool.Lock); }
     return(values);
 }
Example #6
0
 /// <summary>
 /// 获取逆序分页数据集合
 /// </summary>
 /// <typeparam name="arrayType"></typeparam>
 /// <param name="getValue"></param>
 /// <param name="pageSize">分页大小</param>
 /// <param name="currentPage">分页页号</param>
 /// <param name="count">数据总数</param>
 /// <returns>逆序分页数据集合</returns>
 public arrayType[] GetPageDesc <arrayType>(Func <valueType, arrayType> getValue, int pageSize, int currentPage, out int count)
 {
     arrayType[] values = null;
     count = 0;
     Monitor.Enter(cache.SqlTool.Lock);
     try
     {
         array.page page = new array.page(count = tree.Count, pageSize, currentPage);
         values = tree.GetRange(count - page.SkipCount - page.CurrentPageSize, page.CurrentPageSize, getValue);
     }
     finally { Monitor.Exit(cache.SqlTool.Lock); }
     return(values.reverse());
 }
Example #7
0
 /// <summary>
 /// 获取逆序分页数据集合
 /// </summary>
 /// <typeparam name="arrarType"></typeparam>
 /// <param name="index"></param>
 /// <param name="getValue"></param>
 /// <param name="pageSize">分页大小</param>
 /// <param name="currentPage">分页页号</param>
 /// <param name="count">数据总数</param>
 /// <returns>逆序分页数据集合</returns>
 public arrarType[] GetPageDesc <arrarType>(int index, Func <valueType, arrarType> getValue, int pageSize, int currentPage, out int count)
 {
     arrarType[] values = null;
     count = 0;
     fastCSharp.searchTree <sortType, valueType> tree = array[index].Value;
     if (tree != null)
     {
         Monitor.Enter(cache.SqlTool.Lock);
         try
         {
             array.page page = new array.page(count = tree.Count, pageSize, currentPage);
             values = tree.GetRange(count - page.SkipCount - page.CurrentPageSize, page.CurrentPageSize, getValue);
         }
         finally { Monitor.Exit(cache.SqlTool.Lock); }
     }
     return(values.reverse());
 }
Example #8
0
 /// <summary>
 /// 获取逆序分页数据集合
 /// </summary>
 /// <param name="key">关键字</param>
 /// <param name="pageSize">分页大小</param>
 /// <param name="currentPage">分页页号</param>
 /// <param name="count">数据总数</param>
 /// <returns>逆序分页数据集合</returns>
 public valueType[] GetPageDesc(keyType key, int pageSize, int currentPage, out int count)
 {
     valueType[] values = null;
     count = 0;
     Monitor.Enter(cache.SqlTool.Lock);
     try
     {
         list <valueType> list = get(key);
         if (list != null)
         {
             array.page page = new array.page(count = list.Count, pageSize, currentPage);
             values = list.GetSub(count - page.SkipCount - page.CurrentPageSize, page.CurrentPageSize);
         }
     }
     finally { Monitor.Exit(cache.SqlTool.Lock); }
     return(values.reverse());
 }
 ///// <summary>
 ///// 获取逆序数据集合
 ///// </summary>
 ///// <param name="key">关键字</param>
 ///// <returns>逆序数据集合</returns>
 //[MethodImpl((MethodImplOptions)fastCSharp.pub.MethodImplOptionsAggressiveInlining)]
 //public valueType[] GetArrayDesc(keyType key)
 //{
 //    return GetArray(key).reverse();
 //}
 /// <summary>
 /// 获取逆序分页数据集合
 /// </summary>
 /// <param name="key">关键字</param>
 /// <param name="pageSize">分页大小</param>
 /// <param name="currentPage">分页页号</param>
 /// <param name="count">数据总数</param>
 /// <returns>逆序分页数据集合</returns>
 public valueType[] GetPageDesc(keyType key, int pageSize, int currentPage, out int count)
 {
     valueType[] values = null;
     count = 0;
     fastCSharp.searchTree <sortType, valueType> tree;
     Monitor.Enter(cache.SqlTool.Lock);
     try
     {
         if (groups.TryGetValue(key, out tree))
         {
             array.page page = new array.page(count = tree.Count, pageSize, currentPage);
             values = tree.GetRange(count - page.SkipCount - page.CurrentPageSize, page.CurrentPageSize);
         }
     }
     finally { Monitor.Exit(cache.SqlTool.Lock); }
     return(values.reverse());
 }
Example #10
0
 /// <summary>
 /// 获取分页记录集合
 /// </summary>
 /// <param name="pageSize">分页长度</param>
 /// <param name="currentPage">分页页号</param>
 /// <param name="count">记录总数</param>
 /// <returns>分页记录集合</returns>
 public valueType[] GetPageDesc(int pageSize, int currentPage, out int count)
 {
     Monitor.Enter(SqlTool.Lock);
     try
     {
         array.page  page   = new array.page(count = Count, pageSize, currentPage);
         valueType[] values = new valueType[page.CurrentPageSize];
         for (int writeIndex = values.Length, index = getIndex(Count - page.SkipCount - page.CurrentPageSize); writeIndex != 0; values[--writeIndex] = this.values[index++])
         {
             while (this.values[index] == null)
             {
                 ++index;
             }
         }
         return(values);
     }
     finally { Monitor.Exit(SqlTool.Lock); }
 }
Example #11
0
        /// <summary>
        /// 获取逆序分页数据集合
        /// </summary>
        /// <param name="key">关键字</param>
        /// <param name="pageSize">分页大小</param>
        /// <param name="currentPage">分页页号</param>
        /// <param name="isValue">数据匹配器,禁止锁操作</param>
        /// <param name="count">数据总数</param>
        /// <returns>逆序分页数据集合</returns>
        public subArray <valueType> GetPageDescLock
            (keyType key, int pageSize, int currentPage, Func <valueType, bool> isValue, out int count)
        {
            subArray <valueType> values = default(subArray <valueType>);

            count = 0;
            Monitor.Enter(cache.SqlTool.Lock);
            try
            {
                list <valueType> list = get(key);
                if (list != null)
                {
                    valueType[] array = list.UnsafeArray;
                    array.page  page  = new array.page(list.Count, pageSize, currentPage);
                    for (int index = list.Count, skipCount = page.SkipCount, getCount = page.CurrentPageSize; --index >= 0;)
                    {
                        valueType value = array[index];
                        if (isValue(value))
                        {
                            if (skipCount == 0)
                            {
                                if (getCount != 0)
                                {
                                    if (values.UnsafeArray == null)
                                    {
                                        values = new subArray <valueType>(page.CurrentPageSize);
                                    }
                                    values.Add(value);
                                    --getCount;
                                }
                            }
                            else
                            {
                                --skipCount;
                            }
                            ++count;
                        }
                    }
                }
            }
            finally { Monitor.Exit(cache.SqlTool.Lock); }
            return(values);
        }
Example #12
0
 public arrayType[] GetPageDesc <arrayType>(Func <valueType, arrayType> getValue, int pageSize, int currentPage, out int count)
 {
     if (getValue == null)
     {
         fastCSharp.log.Default.Throw(fastCSharp.log.exceptionType.Null);
     }
     array.page page = new array.page(count = length, pageSize, currentPage);
     if (page.CurrentPageSize != 0)
     {
         arrayType[] values = new arrayType[page.CurrentPageSize];
         int         startIndex = this.startIndex + page.DescSkipCount, readIndex = startIndex + page.CurrentPageSize, writeIndex = 0;
         do
         {
             values[writeIndex++] = getValue(array[--readIndex]);
         }while (readIndex != startIndex);
         return(values);
     }
     return(nullValue <arrayType> .Array);
 }
Example #13
0
 /// <summary>
 /// 获取分页数据集合
 /// </summary>
 /// <param name="key">关键字</param>
 /// <param name="pageSize">分页大小</param>
 /// <param name="currentPage">分页页号</param>
 /// <param name="count">数据总数</param>
 /// <returns>分页数据集合</returns>
 public valueType[] GetPage(keyType key, int pageSize, int currentPage, out int count)
 {
     valueType[] values = null;
     Monitor.Enter(cache.SqlTool.Lock);
     try
     {
         list <valueType> list = get(key);
         if (list == null)
         {
             count = 0;
         }
         else
         {
             array.page page = new array.page(count = list.Count, pageSize, currentPage);
             values = list.GetSub(page.SkipCount, page.CurrentPageSize);
         }
     }
     finally { Monitor.Exit(cache.SqlTool.Lock); }
     return(values ?? nullValue <valueType> .Array);
 }
Example #14
0
        /// <summary>
        /// 获取逆序分页数据集合
        /// </summary>
        /// <param name="key">关键字</param>
        /// <param name="pageSize">分页大小</param>
        /// <param name="currentPage">分页页号</param>
        /// <param name="isValue">数据匹配器,禁止锁操作</param>
        /// <param name="count">数据总数</param>
        /// <returns>逆序分页数据集合</returns>
        public list <valueType> GetPageDescLock
            (keyType key, int pageSize, int currentPage, func <valueType, bool> isValue, out int count)
        {
            list <valueType> values = null;

            count = 0;
            Monitor.Enter(cache.SqlTool.Lock);
            try
            {
                list <valueType> list = get(key);
                if (list != null)
                {
                    valueType[] array = list.Unsafer.Array;
                    array.page  page  = new array.page(count = list.Count, pageSize, currentPage);
                    list <valueType> .unsafer valueList = new list <valueType>(pageSize).Unsafer;
                    for (int index = list.Count, skipCount = page.SkipCount, getCount = page.CurrentPageSize; --index >= 0;)
                    {
                        valueType value = array[index];
                        if (isValue(value))
                        {
                            if (skipCount == 0)
                            {
                                valueList.Add(value);
                                if (--getCount == 0)
                                {
                                    break;
                                }
                            }
                            else
                            {
                                --skipCount;
                            }
                        }
                    }
                    values = valueList.List;
                }
            }
            finally { Monitor.Exit(cache.SqlTool.Lock); }
            return(values);
        }
Example #15
0
 /// <summary>
 /// 分页排序
 /// </summary>
 /// <param name="array">待排序数组</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 /*Type[0]*/ ulong /*Type[0]*/[] array, int pageSize, int currentPage)
 {
     array.page page = new array.page(array.length(), pageSize, currentPage);
     return(algorithm.quickSort.GetRangeSort/*Compare[0]*//*Compare[0]*/ (array, page.SkipCount, page.CurrentPageSize));
 }
Example #16
0
 /// <summary>
 /// 分页排序
 /// </summary>
 /// <param name="array">待排序数组</param>
 /// <param name="pageSize">分页尺寸</param>
 /// <param name="currentPage">页号</param>
 /// <returns>分页排序数据</returns>
 public static valueType[] getPageSort/*Compare[0]*//*Compare[0]*/ <valueType>
     (this valueType[] array, func <valueType, /*Type[0]*/ ulong /*Type[0]*/> getKey, int pageSize, int currentPage)
 {
     array.page page = new array.page(array.length(), pageSize, currentPage);
     return(algorithm.quickSort.GetRangeSort/*Compare[0]*//*Compare[0]*/ (array, getKey, page.SkipCount, page.CurrentPageSize));
 }
Example #17
0
 public valueType[] GetPageDesc(int pageSize, int currentPage, out int count)
 {
     array.page page = new array.page(count = length, pageSize, currentPage);
     return(subArray <valueType> .Unsafe(array, startIndex + page.DescSkipCount, page.CurrentPageSize).GetReverse());
 }
Example #18
0
 public subArray <valueType> PageDesc(int pageSize, int currentPage)
 {
     array.page page = new array.page(length, pageSize, currentPage);
     return(subArray <valueType> .Unsafe(array, startIndex + page.DescSkipCount, page.CurrentPageSize).Reverse());
 }
Example #19
0
 public subArray <valueType> Page(int pageSize, int currentPage, out int count)
 {
     array.page page = new array.page(count = length, pageSize, currentPage);
     return(subArray <valueType> .Unsafe(array, startIndex + page.SkipCount, page.CurrentPageSize));
 }
Example #20
0
 public static valueType[] getPageSort/*Compare[0]*//*Compare[0]*/ <valueType>
     (this subArray <valueType> array, Func <valueType, /*Type[0]*/ ulong /*Type[0]*/> getKey, int pageSize, int currentPage, out int count)
 {
     array.page page = new array.page(count = array.Count, pageSize, currentPage);
     return(fastCSharp.algorithm.quickSort.GetRangeSort/*Compare[0]*//*Compare[0]*/ (array.UnsafeArray, 0, count, getKey, page.SkipCount, page.CurrentPageSize));
 }
Example #21
0
 public static subArray </*Type[0]*/ ulong /*Type[0]*/> pageSort/*Compare[0]*//*Compare[0]*/
     (this /*Type[0]*/ ulong /*Type[0]*/[] array, int pageSize, int currentPage)
 {
     array.page page = new array.page(array.length(), pageSize, currentPage);
     return(fastCSharp.algorithm.quickSort.RangeSort/*Compare[0]*//*Compare[0]*/ (array, page.SkipCount, page.CurrentPageSize));
 }