static void FilterTo(double to) { sb.Append("Ok: "); var testProduct = new Product("asd", "asd", to); var products = byPrice.RangeTo(testProduct, true).Take(10); sb.AppendLine(string.Join(", ", products)); }
public void DestroyTargetsInRadius(int radius) { var itemsToRemove = invadersByPriority.RangeTo(new LinkedListNode <Invader>(new Invader(int.MinValue, radius)), true).ToList(); foreach (var node in itemsToRemove) { invadersByInsertion.Remove(node); this.invadersByPriority.Remove(node); } }
public void DestroyTargetsInRadius(int radius) { var toRemove = byPriority.RangeTo(new LinkedListNode <Invader>(new Invader(-1, radius)), false).ToArray(); foreach (var node in toRemove) { byInsertion.Remove(node); } byPriority.RemoveMany(toRemove); }
private static void FilterByMaxPrice(decimal maxValue) { var maxProduct = new Product("random", maxValue, "dawda"); var filteredProducts = productsByPrice.RangeTo(maxProduct, true) .OrderBy(p => p.Price) .ThenBy(p => p.Name) .ThenBy(p => p.Type) .Take(10); if (filteredProducts.Count() > 0) { Console.WriteLine("Ok: {0}", string.Join(", ", filteredProducts)); } else { Console.WriteLine("Ok: "); } }
private static string FilterByPriceTo(string command) { var commandTokens = command.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var result = new StringBuilder(); result.Append("Ok: "); double toPrice = double.Parse(commandTokens[4]); var product = new Product("zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", toPrice, ""); var elements = sortedByPriceProducts.RangeTo(product, true).ToArray(); if (elements.Length > 0) { if (elements.Length >= 10) { for (int i = 0; i < 10; i++) { result.AppendFormat("{0}, ", elements[i].ToString()); } } else { for (int i = 0; i < elements.Length; i++) { result.AppendFormat("{0}, ", elements[i].ToString()); } } result.Length -= 2; } return(result.ToString().Trim()); }