public void Sorting()
 {
     if (_sort != null && _source.Any())
     {
         _source = _sort.Sort(_source);
     }
 }
        private async void StartSorting()
        {
            myInfoBar.IsOpen        = true;
            myInfoBar.Message       = AppResourceManager.GetInstance.GetString("InforBar.Message.ActionInProgress");
            myInfoBar.Severity      = InfoBarSeverity.Warning;
            myProgressRing.IsActive = true;
            DateTime dtStart = DateTime.Now;

            _cancellationTokenSource = new();
            try
            {
                await Task.Run(() =>
                {
                    _sorter.SortCancellationToken = _cancellationTokenSource.Token;
                    _sorter.Sort(_collection);

                    this.DispatcherQueue.TryEnqueue(() =>
                    {
                        TimeSpan time           = DateTime.Now.Subtract(dtStart);
                        myInfoBar.Message       = $"{AppResourceManager.GetInstance.GetString("InforBar.Message.ActionCompleted") } ({time.TotalSeconds.ToString("F")}s)";
                        myInfoBar.Severity      = InfoBarSeverity.Success;
                        myProgressRing.IsActive = false;
                    });
                });
            }
            catch (OperationCanceledException)
            {
                myInfoBar.Message       = AppResourceManager.GetInstance.GetString("InforBar.Message.ActionCancelled");;
                myInfoBar.Severity      = InfoBarSeverity.Error;
                myProgressRing.IsActive = false;
            }
        }
Exemple #3
0
        public void Sort()
        {
            _sortStrategy.Sort(_elements);

            foreach (var item in _elements)
            {
                Console.WriteLine(item);
            }
        }
Exemple #4
0
 public void Sort()
 {
     sortstrategy.Sort(list);
     foreach (string name in list)
     {
         Console.WriteLine(" " + name);
     }
     Console.WriteLine();
 }
Exemple #5
0
 public void TestLinerNodeDependency() {
     var result = sortStrategy.Sort(Nodes.All).ToArray();
     foreach (var node in result) {
         var others = result.Where(x => x.Profile != node.Profile);
         foreach (var other in others) {
             Assert.That(node.Position, Is.Not.EqualTo(other.Position).Within(e));
         }
     }
 }
        public void Sort()
        {
            _sortstrategy.Sort(_list);

            // Iterate over list and display results
            foreach (string name in _list)
            {
                Console.WriteLine(" " + name);
            }
            Console.WriteLine();
        }
Exemple #7
0
        //################################################################################
        #region Internal Implementation

        internal void Sort()
        {
            //sort list
            m_SortStrategy.Sort(m_List);

            //print list
            Console.WriteLine(m_SortStrategy.ToString());
            foreach (int t in m_List)
            {
                Console.WriteLine(t);
            }
        }
 public long Sort(int[] data, ISortStrategy strategy)
 {
     if (!isInited)
     {
         throw new Exception ("Application should be initialized first!");
     }
     System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch ();
     watch.Reset ();
     watch.Start ();
     strategy.Sort (ref data);
     watch.Stop ();
     return watch.ElapsedMilliseconds;
 }
Exemple #9
0
		private static (TimeSpan duration, List<int> sortedData) RunTest(ISortStrategy sortStrategy, List<int> unsortedData, int testsCount)
		{
			var duration = TimeSpan.Zero;
			List<int> sortedData = new List<int>();

			for (int i = 0; i < testsCount; i++)
			{
				var startTime = DateTime.Now;
				sortedData = sortStrategy.Sort(unsortedData);
				duration += DateTime.Now - startTime;

			}
			return (duration, sortedData);
		}
Exemple #10
0
        private GroupedItem <T>[] SortBlock(GroupedItem <T>[] block)
        {
            _Status = SortStatus.Sorting;

            if (_sortStrategy.IsSorted(block))
            {
                return(block);
            }

            block = _sortStrategy.Sort(block);

            _BlocksSorted++;

            return(block);
        }
    public static void AssertTestRowSort(
      string title,
      ISortStrategy<TestLine> strategy,
      int blockSize
    )
    {
      var input = GenerateTestRows(blockSize);
      var expected = input.OrderBy(x => x.String).ThenBy(x => x.Number).Select(x => _parser.Unparse(x)).ToArray();

      var watch = new Stopwatch();
      watch.Start();

      var actual = strategy.Sort(input).Select(x => _parser.Unparse(x)).ToArray();
      watch.Stop();

      Assert.Equal(expected, actual);
    }
Exemple #12
0
        public void TestLinerNodeDependency()
        {
            var nodes = new[] { Nodes._0, Nodes._1 };

            // [0]--->[1]
            Nodes._0.SetRequireNodes(new[] { Profiles._1 });
            NodeProcessor.SetBeRequiredNodes(nodes);

            var result = sortStrategy.Sort(nodes).ToArray();
            var node0  = result.FirstOrDefault(x => x.Profile == Profiles._0);
            var node1  = result.FirstOrDefault(x => x.Profile == Profiles._1);

            Assert.That(node0, Is.Not.Null);
            Assert.That(node0.Position.x, Is.Zero);
            Assert.That(node0.Position.y, Is.Zero);
            Assert.That(node1, Is.Not.Null);
            Assert.That(node1.Position.x, Is.EqualTo(node0.Position.x + d + (w / 2.0F)).Within(e));
            Assert.That(node1.Position.y, Is.EqualTo(node0.Position.y).Within(e));
        }
Exemple #13
0
 public JsonResult Get(int length, bool isAscending = true)
 {
     if (length > 0)
     {
         try
         {
             return(Json(sorting.Sort(new SortDTO {
                 Length = length, IsAscending = isAscending
             })));
         }
         catch (ValidationException e)
         {
             return(Json(e.Message));
         }
     }
     else
     {
         return(Json("length must be greater than zero"));
     }
 }
Exemple #14
0
 public ActionResult Get(int length, bool isAscending = true)
 {
     if (length > 0)
     {
         try
         {
             return(Json(sorting.Sort(new SortDTO {
                 Length = length, IsAscending = isAscending
             })));
         }
         catch (ValidationException e)
         {
             return(Json(e.Message));
         }
     }
     else
     {
         var ObjectRes = StatusCode(400, "length must be greater than zero");
         ObjectRes.StatusCode = 400;
         return(ObjectRes);
     }
     //return Json("length must be greater than zero");
 }
Exemple #15
0
        public CancellationTokenSource StartNew(string fileName, Action <SortFinishedArgs> postSortAction)
        {
            var source = new CancellationTokenSource();
            var token  = source.Token;

            var factory = new TaskFactory(token);

            factory.StartNew(() =>
            {
                ISortStrategy strategy = null;

                try
                {
                    token.Register(Thread.CurrentThread.Abort);
                    var memoryChecker   = new MemoryChecker();
                    var strategyFactory = new SortStrategyFactory(memoryChecker);
                    strategy            = strategyFactory.ChooseSortStrategy(fileName);
                    strategy.Sort();
                    postSortAction(new SortFinishedArgs());
                }
                catch (ThreadAbortException)
                {
                    // do nothing, operation was cancelled
                }
                catch (Exception exception)
                {
                    var args = new SortFinishedArgs(exception);
                    postSortAction(args);
                }
                finally
                {
                    strategy.CleanUp();
                }
            }, token);
            return(source);
        }
 public void Sort()
 {
     _sortStrategy.Sort(_list);
 }
Exemple #17
0
 internal IEnumerable <int> Sort(IEnumerable <int> enums)
 {
     return(_sortStrategy.Sort(enums));
 }
Exemple #18
0
 public List <int> Sort(List <int> unSortedList)    // Creating list method to Sort() unsorted list.
 {
     return(mSorter.Sort(unSortedList));            // Uses ISortStrategy Sorter to
 }
Exemple #19
0
 public List <int> Sort(List <int> list)
 {
     return(_sortStrategy.Sort(list));
 }
 public void Sort()
 {
     _sortStrategy.Sort(_names);
 }
Exemple #21
0
 public void Sort(string[] items)
 {
     sort.Sort(items); // Sorrendezés az aktuális stratégiával
 }
Exemple #22
0
 public static IEnumerable <T> Sort <T>(IEnumerable <T> numbers, ISortStrategy sortStrategy)
 {
     return(sortStrategy.Sort(numbers));
 }
 public IList <int> Sort(IList <int> unSortedList, ISortStrategy sortStrategy) => sortStrategy.Sort(unSortedList);
Exemple #24
0
        public List <string> Sort(List <string> list)
        {
            _sortStrategy.Sort(list);

            return(list);
        }
Exemple #25
0
 public void Sort(ISortStrategy sortstrategy) => sortstrategy.Sort(_list);
Exemple #26
0
 public void Sort(int[] tableToSort)
 {
     _timer.Start();
     _strategy.Sort(tableToSort);
     _timer.Stop();
 }
Exemple #27
0
 public Array Sort(Array dataSet)
 {
     return(sorter.Sort(dataSet));
 }
 public void Sort(ISortStrategy sortStrategy)    //sortStrategy can be passed in constructor or like method parameter.
 {
     sortStrategy.Sort(list);
 }
Exemple #29
0
 public void Sort(ISortStrategy strategy)
 {
     strategy.Sort(list);
 }
Exemple #30
0
 public List <int> Sort(List <int> unSortedList)
 {
     return(mSorter.Sort(unSortedList));
 }
Exemple #31
0
 public void DoSort()
 {
     sort.Sort();
 }