1
0

fix: remove last usage of "List"

This commit is contained in:
Rokas Puzonas 2022-04-20 20:17:26 +03:00
parent 83883e81ef
commit 5c255814ef
2 changed files with 5 additions and 5 deletions

View File

@ -16,7 +16,7 @@ namespace LD_24.Code
/// </summary> /// </summary>
/// <param name="orders">List of orders</param> /// <param name="orders">List of orders</param>
/// <returns>List of products ids</returns> /// <returns>List of products ids</returns>
public static List<string> FindMostPopularProducts(IEnumerable<Order> orders) public static LinkedList<string> FindMostPopularProducts(IEnumerable<Order> orders)
{ {
Dictionary<string, int> productSales = new Dictionary<string, int>(); Dictionary<string, int> productSales = new Dictionary<string, int>();
foreach (Order order in orders) foreach (Order order in orders)
@ -31,7 +31,7 @@ namespace LD_24.Code
} }
} }
List<string> mostPopularProducts = new List<string>(); LinkedList<string> mostPopularProducts = new LinkedList<string>();
int mostPopularCount = 0; int mostPopularCount = 0;
foreach (string product in productSales.Keys) foreach (string product in productSales.Keys)
{ {
@ -39,7 +39,7 @@ namespace LD_24.Code
if (count > mostPopularCount) if (count > mostPopularCount)
{ {
mostPopularCount = count; mostPopularCount = count;
mostPopularProducts = new List<string> { product }; mostPopularProducts = new LinkedList<string> { product };
} else if (count == mostPopularCount) } else if (count == mostPopularCount)
{ {
mostPopularProducts.Add(product); mostPopularProducts.Add(product);
@ -120,7 +120,7 @@ namespace LD_24.Code
/// <param name="products">List of products</param> /// <param name="products">List of products</param>
/// <param name="ids">List of product ids</param> /// <param name="ids">List of product ids</param>
/// <returns>List of products</returns> /// <returns>List of products</returns>
public static LinkedList<Product> FindByID(IEnumerable<Product> products, List<string> ids) public static LinkedList<Product> FindByID(IEnumerable<Product> products, LinkedList<string> ids)
{ {
LinkedList<Product> foundProducts = new LinkedList<Product>(); LinkedList<Product> foundProducts = new LinkedList<Product>();
foreach (string id in ids) foreach (string id in ids)

View File

@ -42,7 +42,7 @@ namespace LD_24
var products = InOutUtils.ReadProducts(FileUpload1.FileContent); var products = InOutUtils.ReadProducts(FileUpload1.FileContent);
var orders = InOutUtils.ReadOrders(FileUpload2.FileContent); var orders = InOutUtils.ReadOrders(FileUpload2.FileContent);
List<string> mostPopularProductIds = TaskUtils.FindMostPopularProducts(orders); var mostPopularProductIds = TaskUtils.FindMostPopularProducts(orders);
var mostPopularProducts = TaskUtils.FindByID(products, mostPopularProductIds); var mostPopularProducts = TaskUtils.FindByID(products, mostPopularProductIds);
var filteredProducts = TaskUtils.FilterByQuantitySoldAndPrice(products, orders, n, k); var filteredProducts = TaskUtils.FilterByQuantitySoldAndPrice(products, orders, n, k);
var customersWithSingleProduct = TaskUtils.FindCustomerWithSingleProduct(orders); var customersWithSingleProduct = TaskUtils.FindCustomerWithSingleProduct(orders);