コード例 #1
0
        public static SortedQueryResultSet <TKey, TValue> GetSortedQueryResultSet <TKey, TValue>(ISet <KeyValuePair <TKey, TValue> > list,
                                                                                                 PagingPredicate <TKey, TValue> pagingPredicate, IterationType iterationType)
        {
            if (list == null || list.Count == 0)
            {
                return(new SortedQueryResultSet <TKey, TValue>());
            }
            IComparer <KeyValuePair <TKey, TValue> > comparer   = SortingUtil.NewComparator(pagingPredicate.GetComparator(), iterationType);
            List <KeyValuePair <TKey, TValue> >      sortedList = new List <KeyValuePair <TKey, TValue> >();

            sortedList.AddRange(list);
            sortedList.Sort(comparer);

            KeyValuePair <int, KeyValuePair <TKey, TValue> > nearestAnchorEntry = pagingPredicate.GetNearestAnchorEntry();
            int nearestPage = nearestAnchorEntry.Key;
            int page        = pagingPredicate.GetPage();
            int pageSize    = pagingPredicate.GetPageSize();
            int begin       = pageSize * (page - nearestPage - 1);
            int size        = sortedList.Count;

            if (begin > size)
            {
                return(new SortedQueryResultSet <TKey, TValue>());
            }
            int end = begin + pageSize;

            if (end > size)
            {
                pageSize = size - begin;
            }

            SetAnchor(sortedList, pagingPredicate, nearestPage);
            List <KeyValuePair <TKey, TValue> > subList = sortedList.GetRange(begin, pageSize);

            return(new SortedQueryResultSet <TKey, TValue>(comparer, subList, iterationType));
        }
コード例 #2
0
 public int Compare(KeyValuePair <object, object> x, KeyValuePair <object, object> y)
 {
     return(SortingUtil.Compare(_comparer, _iterationType, x, y));
 }
コード例 #3
0
 public int Compare(KeyValuePair <TKey, TValue> entry1, KeyValuePair <TKey, TValue> entry2)
 {
     return(SortingUtil.Compare(_comparer, _iterationType, entry1, entry2));
 }