public void addHand(Hand reportHand) { // add the hand in the grouped hands dictionary (ordered by handstrengthorder) List <Hand> hands; if (groupedHands.TryGetValue(reportHand.Strength.StrengthOrder, out hands)) { hands.Add(reportHand); } else { List <Hand> newList = new List <Hand>(); newList.Add(reportHand); groupedHands.Add(reportHand.Strength.StrengthOrder, newList); strengthLabels.Add(reportHand.Strength.StrengthOrder, reportHand.Strength.StrengthLabel); } // add the hand frequencies in the frequencyvalues dictionary (ordered by frequencylabel) Dictionary <string, float> .KeyCollection freqlabels = reportHand.Frequencies.Keys; foreach (string freqLabel in freqlabels) { FrequencyValues frequencyValues; if (groupedFrequencies.TryGetValue(freqLabel, out frequencyValues)) { frequencyValues.AddFrequency(reportHand); } else { FrequencyValues newFreqValues = new FrequencyValues(freqLabel); newFreqValues.AddFrequency(reportHand); groupedFrequencies.Add(freqLabel, newFreqValues); } } }
protected void createFrequencyValues() { groupedFrequencies = new Dictionary <string, FrequencyValues>(); // iterate over all the handgroups (one handgroup per handstrengthorder) foreach (KeyValuePair <int, List <Hand> > handGroup in groupedHands) { // iterate over all the hands in the handstrength group foreach (Hand hand in handGroup.Value) { // iterate over the different betting frequencies for the hand foreach (KeyValuePair <string, float> frequency in hand.Frequencies) { FrequencyValues freqValues; if (groupedFrequencies.TryGetValue(frequency.Key, out freqValues)) { freqValues.AddFrequency(handGroup.Key, frequency.Value, hand.Weight); } else { FrequencyValues newFreqValues = new FrequencyValues(frequency.Key); newFreqValues.AddFrequency(handGroup.Key, frequency.Value, hand.Weight); groupedFrequencies.Add(frequency.Key, newFreqValues); } } } } }