public virtual Response Work() { Logger.Info("Start Work."); Logger.Info($"Initial Players = {Players.Count}"); var stopwatch = new Stopwatch(); SimpleCluster sCluster = null; Player lastPlayer = null; var index = -1; stopwatch.Start(); Clusters.Clear(); for (var i = 0; i < Players.Count; i++) { UpdateIndex(ref sCluster, ref index); sCluster[index] = SelectPlayer(ref lastPlayer)?.ToString(); } stopwatch.Stop(); Logger.Info("Finish Work."); Logger.Info($"Result Clusters = {Clusters.Count}"); Logger.Info($"Work time = {stopwatch.Elapsed}"); return(new Response()); }
protected virtual void UpdateIndex(ref SimpleCluster sCluster, ref int index) { if (sCluster == null) { sCluster = new SimpleCluster(); Clusters.Add(sCluster); } index++; if (index <= 3) { return; } index = 0; sCluster = new SimpleCluster(); Clusters.Add(sCluster); }
private int GetMaxPlayerLenght(SimpleCluster cluster) => cluster.Max(p => p?.Length ?? 1);