public JaggedArraySorter(int[][] arr, ISort sorting, IRowExplorer explorer, bool ascending)
 {            
     JaggetArray = arr;
     this.explorer = explorer;
     GetSortTargets();
     sorting.Sort(JaggetArray, rowsTargets, ascending);
 }
示例#2
0
 public SortObject(ISort sort, int interval)
 {
     Sort = sort;
     Interval = interval;
     OriginalArray = new int[0];
     ControlArray = new int[0];
     ResultArray = new int[0];
     IsComplete = false;
 }
示例#3
0
 private void MeasureSorter(ISort sorter, int[] s)
 {
     Trace.WriteLine("Sort type: " + sorter.GetType().Name);
     Trace.WriteLine("Items to sort: " + s.Length);
     var stopwatch = Stopwatch.StartNew();
     sorter.Sort(s);
     stopwatch.Stop();
     Trace.WriteLine("Result time: " + stopwatch.Elapsed);
 }
示例#4
0
        private static void PerfSort(int[] input, ISort<int[]> sortAlgorithm, string type)
        {
            Console.WriteLine(string.Format("{0} sorting started", type));
            var watch = Stopwatch.StartNew();

            sortAlgorithm.Sort(input);

            Console.WriteLine(string.Format("{0} sorting finished in {1} miliseconds", type, watch.ElapsedMilliseconds));
        }
示例#5
0
 public Thead(ISort sort, string text, string column, Func<string, SortDirection?, string> urlBuilder,
     string @class)
 {
     this.sort = sort;
     this.text = text;
     this.column = column;
     this.urlBuilder = urlBuilder;
     direction = sort.GetSortDataFor(column);
     this.@class = @class;
 }
示例#6
0
        static void SortPerfomance(int[] array, ISort sortAlgorithm)
        {
            Stopwatch stopWatch = new Stopwatch();
            stopWatch.Start();
            array = sortAlgorithm.Sort<int>(array, Comparer<int>.Default);

            stopWatch.Stop();
            TimeSpan t = stopWatch.Elapsed;

            string elapsedTime = String.Format('\t' + "{0:00}:{1:00}:{2:00}.{3:00}", t.Hours, t.Minutes, t.Seconds, t.Milliseconds / 10);

            Console.WriteLine(elapsedTime);
        }
示例#7
0
 private void EmptyTest(ISort sort)
 {
     RunTest(sort, new List <int>());
 }
示例#8
0
 internal void OrderBy(ISort sort)
 {
     SlimLock.EnterWriteLock();
     try
     {
         sorting = sort;
     }
     finally
     {
         SlimLock.ExitWriteLock();
     }
 }
示例#9
0
 public ExternalMergeSort(IExternalMergeSortOwner <T> owner, Comparison <T> comparison, ISort sorter)
 {
     Guard.IsNotNull(owner, nameof(owner));
     Guard.IsNotNull(comparison, nameof(comparison));
     Guard.IsNotNull(sorter, nameof(sorter));
     CheckOwner(owner);
     this.owner      = owner;
     this.comparison = comparison;
     this.sorter     = sorter;
 }
示例#10
0
        private void RunTest(ISort sort, IList <int> source)
        {
            var result = sort.Sort(source, (a, b) => a < b);

            VerifyTestResult(source, result);
        }
 public BinaryInsertSortTests()
 {
     sort      = new BinaryInsertSort <int>();
     algorithm = nameof(BinaryInsertSort <int>);
     sortType  = SortType.Insertion;
 }
示例#12
0
 public void Sort(ISort sorter, Comparison <T> comparison)
 {
     sorter.Sort(Data, comparison);
 }
示例#13
0
 private SortDescriptor <T> AddSort(ISort sort) => sort == null ? this : this.Assign(a => a.Add(sort));
示例#14
0
        public IEnumerable <Object> SpinReport(IFilterBuilder userFilter, IFilterBuilder eventFilter, ISort sort, int skip, int limit)
        {
            IMongoQuery query      = new MongoFilterVisitor(userFilter.Build()).Build();
            IMongoQuery eventQuery = new MongoFilterVisitor(eventFilter.Build()).Build();

            var aggQuery = new AggregationBuilder("UserXUserEvent")
                           .Match(query)
                           .Project(registrationReportFields)
                           .Unwind("UserEvents")
                           .Match(eventQuery)
                           .Sort(sort)
                           .Skip(skip)
                           .Limit(limit)
                           .Pipeline;

            return(AggregationResultToList(RunAggreation(aggQuery)));
        }
示例#15
0
        private static void Sort(ISort<int> sorter, int[] array)
        {
            stopwatch.Start();
            sorter.Sort(array);
            stopwatch.Stop();

            Console.WriteLine("{0} - {1:00} ms", sorter.Name, stopwatch.Elapsed.TotalMilliseconds);

            stopwatch.Reset();
        }
示例#16
0
 public Group(int Number)
 {
     this.Number = Number;
     Heir        = Program.container.GetInstance <ISort>();
 }
示例#17
0
 public static void Sort(ISort sort, ArrayList inArray)
 {
     var result = sort.Sort(inArray);
     Console.WriteLine(result.ToString().Split(' '));
 }
示例#18
0
        public IEnumerable <IPrize> GetPrizesGridData(IFilterBuilder userFilter, IFilterBuilder prizeFilter, int skip, int limit, ISort sort)
        {
            var pzsList = PrizesData(userFilter, prizeFilter, skip, limit, sort).ToList();

            var list = BsonSerializer.Deserialize <List <Prize> >(pzsList.ToJson());

            //// pzsList.Add(tObj);
            //tObj.Result = Result.ConvertAll(o => (IPrize))
            return(list);
        }
示例#19
0
        //private MongoCursor<UserEvent> GetEventsCursor(ObjectId campaignId,
        //    IEnumerable<EventTypeEnum> eventTypes, DateTime? start, DateTime? end)
        //{
        //    var query = Query.And(Query.EQ("CampaignId", campaignId),
        //                          Query.In("EventTypeId", eventTypes.Select(x => BsonValue.Create((int)x))));
        //    if (start.HasValue)
        //        query = Query.And(query, Query.GTE("EventDate", start.Value.ToUniversalTime().Ticks));

        //    if (end.HasValue)
        //        query = Query.And(query, Query.LTE("EventDate", end.Value.ToUniversalTime().Ticks));

        //    query = Query.And(query, Query.NE("Hidden", true));
        //    return Context..SlaveServerCollection.FindAs<UserEvent>(query);
        //}

        public IEnumerable <Object> WinsReport(IFilterBuilder userFilter, IFilterBuilder prizeFilter, ISort sort, int skip, int limit)
        {
            IMongoQuery query = null;

            if (userFilter != null)
            {
                query = new MongoFilterVisitor(userFilter.Build()).Build();
            }
            var queryPrize = Query.And(Query.Exists("Prizes._v"),
                                       Query.Not(Query.Size("Prizes._v", 0)),
                                       Query.NE("Hidden", true));

            if (query != null)
            {
                query = Query.And(queryPrize, query);
            }
            else
            {
                query = queryPrize;
            }
            var aggQuery = new AggregationBuilder("User")
                           .Match(query)
                           .Project(winReportFields)
                           .Unwind("$Prizes._v")
                           .Match(new MongoFilterVisitor(prizeFilter.Build()).Build())
                           .Sort(sort)
                           .Skip(skip)
                           .Limit(limit).Pipeline;

            //Console.WriteLine(aggQuery.ToString());
            return(AggregationResultToList(RunAggreation(aggQuery)));
        }
示例#20
0
 protected IEnumerable <Object> PrizesData(IFilterBuilder userFilter, IFilterBuilder prizeFilter, int skip, int limit, ISort sort)
 {
     return(AggregationResultToList(
                RunAggreation(
                    PrizesGraphBase(userFilter, prizeFilter).Sort(sort).Skip(skip).Limit(limit).Pipeline)));
 }
        /// <summary>
        /// Find with transaction
        /// </summary>
        public IList <PM_ALT_ELEMENT> Find(int pageIndex, int pageSize, IFilter filter, ISort sort, out long totalRecords, DbTransaction transaction)
        {
            ArgumentValidator.CheckForNullArgument(transaction, "transaction");

            if (pageIndex < 0)
            {
                throw new ArgumentOutOfRangeException("pageIndex");
            }

            if (pageSize < -1)
            {
                throw new ArgumentOutOfRangeException("pageSize");
            }

            IList <PM_ALT_ELEMENT> PM_ALT_ELEMENTList = new List <PM_ALT_ELEMENT>();

            totalRecords = 0;

            string cmdText;
            string cmdCountText;

            int beginIndex = pageSize * pageIndex;

            string filterClause = "";

            if (filter == null || String.IsNullOrEmpty(filter.ToQueryString()))
            {
            }
            else
            {
                filterClause = filter.ToQueryString();
            }

            string sortClause = "";

            if (sort == null || String.IsNullOrEmpty(sort.ToSortString()))
            {
                sortClause = "ORDER BY ElementID";
            }
            else
            {
                sortClause = sort.ToSortString();
            }

            cmdCountText = string.Format(CultureInfo.InvariantCulture, SqlCount, filterClause);

            if (pageSize == -1)
            {
                cmdText = string.Format(
                    CultureInfo.InvariantCulture, PM_ALT_ELEMENTDAO.SqlSelectAll, filterClause, sortClause);
            }
            else
            {
                cmdText = String.Format(
                    CultureInfo.InvariantCulture,
                    PM_ALT_ELEMENTDAO.SqlSelect, pageSize.ToString(), filterClause, beginIndex.ToString(), filterClause, sortClause, sortClause);
            }

            try
            {
                Database db = GetDatabaseInstance();

                if (pageSize != 0)
                {
                    DbCommand dbCommand = db.GetSqlStringCommand(cmdText);
                    using (IDataReader dataReader = db.ExecuteReader(dbCommand, transaction))
                    {
                        while (dataReader.Read())
                        {
                            PM_ALT_ELEMENTList.Add(ReadEntity(dataReader));
                        }
                    }
                }

                DbCommand dbCommandCount = db.GetSqlStringCommand(cmdCountText);
                totalRecords = Convert.ToInt64(db.ExecuteScalar(dbCommandCount, transaction));
            }
            catch (Exception ex)
            {
                ExceptionPolicy.HandleException(ex, ExceptionPolicy.DataAccessDefaultPolicy);
            }

            return(PM_ALT_ELEMENTList);
        }
示例#22
0
 public BubbleSortTests()
 {
     sort      = new BubbleSort <int>();
     algorithm = nameof(BubbleSort <int>);
 }
示例#23
0
        public IEnumerable <Object> WinnersReport(IFilterBuilder userFilter, IFilterBuilder prizeFilter, ISort sort, int skip, int limit)

        /**
         * > db.User.aggregate(
         * {$match: { CampaignId: ObjectId("5011b6099610f710f4fd438e"), PrizeCount: {$gt:3}}}, # user fields
         * {$project: { LastName: 1, Prizes:1} } # return fields and Prizes
         * {$unwind: '$Prizes._v'}, # unwind the prizes
         * {$match: {"Prizes._v.PrizeDate": {$gte: NumberLong("634794549227340147"), $lte: NumberLong("634794559975708161")}}}
         * # match on prizes
         * {$group: { _id: { _id: '$_id', LastName: '$LastName' ....}, # re-group all the fields you want to see except...
         * "Prizes" : { $addToSet: '$Prizes._v'}}}, # prizes, which you add to set (and now they are unsorted!)
         * {$project: { _id: "$_id._id", LastName:"$_id.LastName", Prizes: 1}}) # project out of _id to get to top level
         */


        {
            IMongoQuery userQuery = null;

            if (userFilter != null)
            {
                userQuery = new MongoFilterVisitor(userFilter.Build()).Build();
            }
            var queryPrize = Query.And(Query.Exists("Prizes._v"),
                                       Query.Not(Query.Size("Prizes._v", 0)),
                                       Query.NE("Hidden", true));

            userQuery = userQuery != null?Query.And(queryPrize, userQuery) : queryPrize;

            IMongoQuery prizeQuery = new MongoFilterVisitor(prizeFilter.Build()).Build();

            var groupFields  = winnersReportFields.Keys.Where(x => !x.StartsWith("Prizes")).ToList();
            var id           = FieldDocument("$", groupFields);
            var finalProject = FieldDocument("$_id.", groupFields).Add("Prizes", 1);

            var group = new BsonDocument {
                { "_id", id }, { "Prizes", new BsonDocument("$addToSet", "$Prizes._v") }
            };


            var aggQuery = new AggregationBuilder("User")
                           .Match(userQuery)
                           .Project(winnersReportFields)
                           .Unwind("$Prizes._v")
                           .Match(prizeQuery)
                           .Group(group)
                           .Project(finalProject)
                           .Sort(sort)
                           .Skip(skip)
                           .Limit(limit).Pipeline;

            //Console.WriteLine(aggQuery.ToString());
            return(AggregationResultToList(RunAggreation(aggQuery)));
        }
示例#24
0
 public MergeSortTests()
 {
     sort      = new MergeSort <int>();
     algorithm = nameof(MergeSort <int>);
 }
示例#25
0
 public void SetSorter(ISort strategy)
 {
     this.strategy = strategy;
 }
示例#26
0
 public void Add(ISort item)
 {
     _Items.Add(item);
 }
示例#27
0
 public WordFrequencyCounter(IParseLogic <string> parseLogic, ISort <Dictionary <string, int> > sortLogic)
 {
     this.parseLogic = parseLogic;
     this.sortLogic  = sortLogic;
 }
示例#28
0
 public QuickDualPivotSortBinaryInsertTests()
 {
     sort      = new QuickDualPivotSortBinaryInsert <int>();
     algorithm = nameof(QuickDualPivotSortBinaryInsert <int>);
     sortType  = SortType.Partition;
 }
示例#29
0
 private static IQueryable <T> SortQueryable <T>(IQueryable <T> queryable, ISort sort)
     where T : class
 {
     sort = sort ?? new RandomSort();
     return(queryable.OrderBy(sort));
 }
示例#30
0
 public ExternalMergeSort(IExternalMergeSortOwner <T> owner, ISort sorter)
     : this(owner, ComparisonCore.Compare, sorter)
 {
 }
示例#31
0
 private static IQueryable <T> SortEnumerable <T>(IEnumerable <T> enumerable, ISort sort)
     where T : class
 {
     sort = sort ?? new RandomSort();
     return(enumerable.AsQueryable().OrderBy(sort));
 }
示例#32
0
 public CocktailShakerSortTests()
 {
     sort      = new CocktailShakerSort <int>();
     algorithm = nameof(CocktailShakerSort <int>);
 }
示例#33
0
 public Sorter(ISort sort)
 {
     this.msort = sort;
 }
示例#34
0
 private void Test1(ISort sort)
 {
     RunTest(sort, _testData1);
 }
示例#35
0
 public NumberCollection()
 {
     this.SortType = new MergeSort();
 }
示例#36
0
 public SortRunner(ISort sort)
 {
     _sort = sort;
 }
示例#37
0
文件: Program.cs 项目: raghur/SOLID
 public Program(IFileWrapper fw, ISort sorter, TextWriter tw)
 {
     this.filewrapper = fw;
     this.sorter = sorter;
     this.writer = tw;
 }
示例#38
0
 public Thead(ISort sort, string text, string column, Func<string, SortDirection?, string> urlBuilder)
     : this(sort, text, column, urlBuilder, null)
 {
 }
 public GnomeSortTests()
 {
     sort      = new GnomeSort <int>();
     algorithm = nameof(GnomeSort <int>);
     sortType  = SortType.Exchange;
 }
示例#40
0
 public CycleSortTests()
 {
     sort      = new CycleSort <int>();
     algorithm = nameof(CycleSort <int>);
 }
 public IntroSortMedian9Tests()
 {
     sort      = new IntroSortMedian9 <int>();
     algorithm = nameof(IntroSortMedian9 <int>);
 }
        public void AddSort([NotNull] ISort <T, object>?sort)
        {
            ThrowHelper.ThrowIfIsNull(sort, nameof(sort));

            _sorts.Add(sort);
        }
示例#43
0
 // Find view entities that fit to some query rules
 // IFilter: only query specific user or department
 // ISort: order by
 public IList<DeptInfo> Find(int pageIndex, int pageSize, IFilter filter, ISort sort, out long totalRecords);