public JaggedArraySorter(int[][] arr, ISort sorting, IRowExplorer explorer, bool ascending) { JaggetArray = arr; this.explorer = explorer; GetSortTargets(); sorting.Sort(JaggetArray, rowsTargets, ascending); }
public SortObject(ISort sort, int interval) { Sort = sort; Interval = interval; OriginalArray = new int[0]; ControlArray = new int[0]; ResultArray = new int[0]; IsComplete = false; }
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); }
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)); }
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; }
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); }
private void EmptyTest(ISort sort) { RunTest(sort, new List <int>()); }
internal void OrderBy(ISort sort) { SlimLock.EnterWriteLock(); try { sorting = sort; } finally { SlimLock.ExitWriteLock(); } }
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; }
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; }
public void Sort(ISort sorter, Comparison <T> comparison) { sorter.Sort(Data, comparison); }
private SortDescriptor <T> AddSort(ISort sort) => sort == null ? this : this.Assign(a => a.Add(sort));
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))); }
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(); }
public Group(int Number) { this.Number = Number; Heir = Program.container.GetInstance <ISort>(); }
public static void Sort(ISort sort, ArrayList inArray) { var result = sort.Sort(inArray); Console.WriteLine(result.ToString().Split(' ')); }
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); }
//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))); }
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); }
public BubbleSortTests() { sort = new BubbleSort <int>(); algorithm = nameof(BubbleSort <int>); }
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))); }
public MergeSortTests() { sort = new MergeSort <int>(); algorithm = nameof(MergeSort <int>); }
public void SetSorter(ISort strategy) { this.strategy = strategy; }
public void Add(ISort item) { _Items.Add(item); }
public WordFrequencyCounter(IParseLogic <string> parseLogic, ISort <Dictionary <string, int> > sortLogic) { this.parseLogic = parseLogic; this.sortLogic = sortLogic; }
public QuickDualPivotSortBinaryInsertTests() { sort = new QuickDualPivotSortBinaryInsert <int>(); algorithm = nameof(QuickDualPivotSortBinaryInsert <int>); sortType = SortType.Partition; }
private static IQueryable <T> SortQueryable <T>(IQueryable <T> queryable, ISort sort) where T : class { sort = sort ?? new RandomSort(); return(queryable.OrderBy(sort)); }
public ExternalMergeSort(IExternalMergeSortOwner <T> owner, ISort sorter) : this(owner, ComparisonCore.Compare, sorter) { }
private static IQueryable <T> SortEnumerable <T>(IEnumerable <T> enumerable, ISort sort) where T : class { sort = sort ?? new RandomSort(); return(enumerable.AsQueryable().OrderBy(sort)); }
public CocktailShakerSortTests() { sort = new CocktailShakerSort <int>(); algorithm = nameof(CocktailShakerSort <int>); }
public Sorter(ISort sort) { this.msort = sort; }
private void Test1(ISort sort) { RunTest(sort, _testData1); }
public NumberCollection() { this.SortType = new MergeSort(); }
public SortRunner(ISort sort) { _sort = sort; }
public Program(IFileWrapper fw, ISort sorter, TextWriter tw) { this.filewrapper = fw; this.sorter = sorter; this.writer = tw; }
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; }
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); }
// 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);