From 5a08f6a8b88bbe07ca75abac6773c6734fc55923 Mon Sep 17 00:00:00 2001 From: Chomp Date: Tue, 4 Feb 2025 18:17:24 +0000 Subject: [PATCH] Improved variable names --- .../Core/Utils/Collections/ProbabilityObjectArray.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Libraries/Core/Utils/Collections/ProbabilityObjectArray.cs b/Libraries/Core/Utils/Collections/ProbabilityObjectArray.cs index 7ca8fe35..b8ada3df 100644 --- a/Libraries/Core/Utils/Collections/ProbabilityObjectArray.cs +++ b/Libraries/Core/Utils/Collections/ProbabilityObjectArray.cs @@ -144,13 +144,13 @@ public class ProbabilityObjectArray : List where T : ProbabilityObje * Draw random element of the ProbabilityObject N times to return an array of N keys. * Drawing can be with or without replacement * @param count The number of times we want to draw - * @param replacement Draw with or without replacement from the input dict (true = dont remove after drawing) + * @param removeAfterDraw Draw with or without replacement from the input dict (true = dont remove after drawing) * @param lockList list keys which shall be replaced even if drawing without replacement * @returns Array consisting of N random keys for this ProbabilityObjectArray */ - public List Draw(int count = 1, bool replacement = true, List? lockList = null) + public List Draw(int drawCount = 1, bool removeAfterDraw = true, List? neverRemoveWhitelist = null) { - lockList ??= []; + neverRemoveWhitelist ??= []; if (Count == 0) { return []; @@ -169,12 +169,12 @@ public class ProbabilityObjectArray : List where T : ProbabilityObje var probCumsum = CumulativeProbability(totals.probArray); var drawnKeys = new List(); - for (var i = 0; i < count; i++) + for (var i = 0; i < drawCount; i++) { var rand = Random.Shared.NextDouble(); var randomIndex = (int)probCumsum.FindIndex((x) => x > rand); // We cannot put Math.random() directly in the findIndex because then it draws anew for each of its iteration - if (replacement || lockList.Contains(totals.keyArray[randomIndex])) + if (removeAfterDraw || neverRemoveWhitelist.Contains(totals.keyArray[randomIndex])) { // Add random item from possible value into return array drawnKeys.Add(totals.keyArray[randomIndex]);