本文整理汇总了C#中IList.OrderByDescending方法的典型用法代码示例。如果您正苦于以下问题:C# IList.OrderByDescending方法的具体用法?C# IList.OrderByDescending怎么用?C# IList.OrderByDescending使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IList
的用法示例。
在下文中一共展示了IList.OrderByDescending方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LargestStock
private static void LargestStock(IList<double> cuts, IList<Board> stockList)
{
var longest = stockList.OrderByDescending(x => x.Length).First();
var longestBoard = longest.Length;
var boardCost = longest.Price;
var scraps = new List<double>();
var stockUsed = new List<Board>();
while (cuts.Any())
{
var longestCut = cuts.OrderByDescending(x => x).First();
cuts.Remove(longestCut);
if (scraps.Any(x => x > longestCut))
{
scraps = scraps.CutFromScrap(longestCut);
}
else
{
stockUsed.Add(longest);
scraps.Add(longestBoard - longestCut - kerf);
}
}
Console.WriteLine("Total number of boards used: {0}", stockUsed.Count());
Console.WriteLine("Total Cost: {0}", stockUsed.Count() * boardCost);
OutputWaste(scraps, stockUsed.Count() * longestBoard);
}
示例2: VisaData
public void VisaData(IList<AktivPeriod> perioder)
{
panel1.Controls.Clear();
double pixlarPerDygn = 1000;// (double)panel1.Width;
var förstaTimme = perioder.OrderBy(o => o.Starttid.Hour).FirstOrDefault().Starttid.Hour;
var sistaTimme = perioder.OrderBy(o => o.Starttid.Hour).LastOrDefault().Starttid.Hour;
var daghöjd = 30;
var marginal = 10;
var vänsterMarginal = 120;
var minutlängd = (pixlarPerDygn - vänsterMarginal) / (sistaTimme - förstaTimme) / 60; // pixlarPerDygn / 24 / 60;
var position = 0;
for (int timme = förstaTimme; timme <= sistaTimme; timme++)
{
var timstreck = new TimMarkering(timme);
timstreck.Top = 0;
timstreck.Left = (int)(position * minutlängd * 60) + vänsterMarginal;
panel1.Controls.Add(timstreck);
position++;
}
var y = marginal + daghöjd;
foreach (var period in perioder.OrderByDescending(o => o.Starttid).GroupBy(o => o.Starttid.Date).Select(o =>
new
{
Datum = o.Key,
Perioder = o
}))
{
var daglabel = new Label();
daglabel.Top = y;
daglabel.Left = marginal;
daglabel.Text = period.Datum.ToString("dddd, d MMM");
panel1.Controls.Add(daglabel);
foreach (var item in period.Perioder)
{
var aktivitet = new Aktivitetsmarkering(item);
aktivitet.BackColor = System.Drawing.Color.Blue;
aktivitet.Top = y;
aktivitet.Height = daghöjd;
aktivitet.Width = (int)(minutlängd * item.Tidsmängd.TotalMinutes);
if (aktivitet.Width == 0) aktivitet.Width = 1;
aktivitet.Left = (int)(item.Starttid.Subtract(period.Datum).TotalMinutes * minutlängd) + vänsterMarginal - (int)(förstaTimme * 60 * minutlängd);
panel1.Controls.Add(aktivitet);
}
y += daghöjd + marginal;
}
}
示例3: ChooseSets
public static List<int[]> ChooseSets(IList<int[]> sets, IList<int> universe)
{
var selectedSets = new List<int[]>();
while (universe.Count > 0)
{
var currentSet = sets.OrderByDescending(s => s.Count(universe.Contains)).First();
selectedSets.Add(currentSet);
sets.Remove(currentSet);
universe = universe.Except(currentSet).ToList();
}
return selectedSets;
}
示例4: Update
public void Update(IList<ICreature> creatures, IList<Tuple<ObjectType, IList<double>>> objects, MineSweeperSettings settings)
{
Image = new Bitmap(Width, Height);
using (var graphics = Graphics.FromImage(Image))
{
var eliteSweeperPen = new Pen(_bestColor);
var sweeperPen = new Pen(_neutralColor);
var minePen = new Pen(Color.DarkGray);
var blackPen = new Pen(Color.Black);
var redPen = new Pen(Color.Maroon);
// Elite Sweepers
foreach (var sweeper in creatures.OrderByDescending(x => x.Fitness).Take(settings.EliteCount))
{
drawSweeper(graphics, eliteSweeperPen, eliteSweeperPen.Brush, sweeper, settings.SweeperSize);
}
// Normal Sweepers
foreach (var sweeper in creatures.OrderByDescending(x => x.Fitness).Skip(settings.EliteCount))
{
drawSweeper(graphics, sweeperPen, sweeperPen.Brush, sweeper, settings.SweeperSize);
}
// Mines
var mines = objects.Where(x => x.Item1 == ObjectType.Mine).Select(x => x.Item2);
foreach (var mine in mines)
{
drawMine(graphics, redPen, minePen.Brush, mine, settings.MineSize);
}
// ClusterMines
var clusterMines = objects.Where(x => x.Item1 == ObjectType.ClusterMine).Select(x => x.Item2);
foreach (var mine in clusterMines)
{
drawMine(graphics, blackPen, sweeperPen.Brush, mine, settings.MineSize + 1);
}
// Holes
var holes = objects.Where(x => x.Item1 == ObjectType.Hole).Select(x => x.Item2);
foreach (var hole in holes)
{
drawMine(graphics, redPen, redPen.Brush, hole, settings.MineSize + 1);
}
eliteSweeperPen.Dispose();
sweeperPen.Dispose();
minePen.Dispose();
blackPen.Dispose();
redPen.Dispose();
}
}
示例5: SubmissionCandidatesViewModel
/// <summary>
/// Constructor.
/// </summary>
public SubmissionCandidatesViewModel(
User user,
IList<Commit> commits,
Func<Commit, string> commitUrlBuilder,
Checkpoint checkpoint,
Model.Projects.Submission latestSubmission,
ITimeZoneProvider timeZoneProvider)
{
User = user;
Checkpoint = checkpoint;
Candidates = commits
.OrderByDescending(commit => commit.PushDate)
.ThenByDescending(commit => commit.CommitDate)
.Select
(
commit => new SubmissionCandidateViewModel
(
commit,
commitUrlBuilder(commit),
latestSubmission?.CommitId == commit.Id,
commit == commits.First(),
timeZoneProvider
)
).ToList();
}
示例6: ABMCierreY
public ABMCierreY(CierreY cy)
{
InitializeComponent();
CargarCombo();
dpCierre.Value = DateTime.Now;
dpApertura.Value = DateTime.Now;
if (cy.Id != 0)
{
cierreY = new CierreY();
cierreY = cy;
cbCaja.Enabled = false;
cbCajero.Enabled = false;
CargarDatos();
}
else
{
listaY = gestorz.buscarCierreY(true, 0);
listaY = listaY.OrderByDescending(c => c.Numero).ToList();
if (listaY.Count > 0)
{
CierreY ciey = new CierreY();
ciey = listaY[0];
txtNumero.Text = (ciey.Numero + 1).ToString();
}
else
{ txtNumero.Text = "1"; }
}
txtRendido.Focus();
}
示例7: RuleResolver
public RuleResolver(IList<Rule> rules )
{
if(rules == null || rules.Count == 0)
throw new ArgumentException("wrong format","rules");
_rules = rules.OrderByDescending(x=>x.PriceTemplate.CountFixedDigits).ToList();
}
示例8: ChooseCoins
public static Dictionary<int, int> ChooseCoins(IList<int> coins, int targetSum)
{
var sortedCoins = coins.OrderByDescending(coin => coin)
.ToList();
var chosenCoin= new Dictionary<int,int>();
var currentSum = 0;
var coinIndex = 0;
while (currentSum != targetSum && coinIndex< sortedCoins.Count)
{
var currentCoinValue = sortedCoins[coinIndex];
var remainingSum = targetSum - currentSum;
var numberOfCoinToTake = remainingSum / currentCoinValue;
if (numberOfCoinToTake>0)
{
chosenCoin[currentCoinValue] = numberOfCoinToTake;
currentSum += currentCoinValue * numberOfCoinToTake;
}
coinIndex++;
}
if (currentSum != targetSum)
{
throw new InvalidOperationException("Target sum can not be reached");
}
return chosenCoin;
}
示例9: cargarDatos
public void cargarDatos()
{
listaZ = gestor.buscar(false, 0, new EstadoCierreZ(), DateTime.MinValue, DateTime.MinValue);
listaZ = listaZ.OrderByDescending(cz => cz.Numero).ToList();
if (listaZ.Count > 0)
{
cierreZ = new CierreZ();
cierreZ = listaZ[0];
txtFinal.Text = cierreZ.SaldoFinal.ToString();
txtNumero.Text = cierreZ.Numero.ToString();
txtRendido.Text = cierreZ.SaldoRendido.ToString();
txtSaldoInicial.Text = cierreZ.SaldoInicial.ToString();
dpApertura.Value = cierreZ.Apertura;
listacierrey = cierreZ.ListaCierreY;
txtEstado.Text = cierreZ.EstadoCierrez.Descripcion;
cargarGrilla();
Utils.habilitar(true, txtNumero, btnBuscar);
}
else
{
estadoInicial();
MessageBox.Show("No hay cierrezZ", "Atención");
}
}
示例10: ChooseCoins
public static Dictionary<int, int> ChooseCoins(IList<int> coins, int targetSum)
{
var sortedCoins = coins.OrderByDescending(c => c).ToList();
var chosenCoins = new Dictionary<int, int>();
var currentSum = 0;
int coinIndex = 0;
while (currentSum != targetSum && coinIndex < sortedCoins.Count)
{
var currentCoinValue = sortedCoins[coinIndex];
var remainingSum = targetSum - currentSum;
var numberOfCoinsToTake = remainingSum / currentCoinValue;
if (numberOfCoinsToTake > 0)
{
if (!chosenCoins.ContainsKey(currentCoinValue))
{
chosenCoins[currentCoinValue] = 0;
}
chosenCoins[currentCoinValue] += numberOfCoinsToTake;
currentSum += currentCoinValue * numberOfCoinsToTake;
}
coinIndex++;
}
if (currentSum != targetSum)
{
throw new InvalidOperationException("Greedy algorithm cannot produce desired sum with specified coins.");
}
return chosenCoins;
}
示例11: GetContainerCombinations
/// <summary>
/// Returns the combinations of containers that can be used to completely fill
/// one or more containers completely with the specified total volume of eggnog.
/// </summary>
/// <param name="volume">The volume of eggnog.</param>
/// <param name="containerVolumes">The volumes of the containers.</param>
/// <returns>
/// The combinations of containers that can store the volume specified by <paramref name="volume"/>.
/// </returns>
internal static IList<ICollection<long>> GetContainerCombinations(int volume, IList<int> containerVolumes)
{
var containers = containerVolumes
.OrderByDescending((p) => p)
.ToList();
return Maths.GetCombinations(volume, containers);
}
示例12: PerformSelectChromosomes
/// <summary>
/// Selects the chromosomes which will be reinserted.
/// </summary>
/// <returns>The chromosomes to be reinserted in next generation..</returns>
/// <param name="population">The population.</param>
/// <param name="offspring">The offspring.</param>
/// <param name="parents">The parents.</param>
protected override IList<IChromosome> PerformSelectChromosomes(Population population, IList<IChromosome> offspring, IList<IChromosome> parents)
{
if (offspring.Count > population.MaxSize) {
return offspring.OrderByDescending (o => o.Fitness).Take (population.MaxSize).ToList ();
}
return offspring;
}
示例13: PrintWall
public void PrintWall(IList<Message> messages)
{
DateTime now = _Clock.CurrentDateAndTime;
foreach (var message in messages.OrderByDescending(a => a.Time))
{
string humanizedTimeSpan = GetHumanizedTimeSpan(now.Subtract(message.Time));
var formattedMessage = string.Format("{0} - {1} ({2} ago)", message.Author.Name, message.Text, humanizedTimeSpan);
_Console.WriteLine(formattedMessage);
}
}
示例14: Print
public void Print(IList<Transaction> transactions)
{
_Console.WriteLine(StatementHeader);
var balance = new Money(transactions.Sum(a => a.Money.Amount));
foreach (var transaction in transactions.OrderByDescending(a => a.Date))
{
_Console.WriteLine(GetFormattedLine(transaction, balance));
balance.Amount -= transaction.Money.Amount;
}
}
示例15: SimulationEngine
/// <summary>
/// Initializes a new instance of the <see cref="SimulationEngine"/> class.
/// </summary>
/// <param name="historicalTasks">The historical tasks.</param>
public SimulationEngine(IList<Task> historicalTasks)
{
if (historicalTasks != null)
{
// Sorts the tasks with the newest first:
this.historicalTasks
= historicalTasks
.OrderByDescending(t => t.EndDate)
.ToList();
}
}