MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / top

Method top

src/Savegame/WeightedOptions.cpp:55–73  ·  view source on GitHub ↗

* Select the most likely option. * This MUST be called on non-empty objects. * @return The key of the selected choice. */

Source from the content-addressed store, hash-verified

53 * @return The key of the selected choice.
54 */
55const std::string WeightedOptions::top() const
56{
57 if (_totalWeight == 0)
58 {
59 return "";
60 }
61 size_t max = 0;
62 std::map<std::string, size_t>::const_iterator i = _choices.begin();
63 for (std::map<std::string, size_t>::const_iterator ii = _choices.begin(); ii != _choices.end(); ++ii)
64 {
65 if (ii->second >= max)
66 {
67 max = ii->second;
68 i = ii;
69 }
70 }
71 // We always have a valid iterator here.
72 return i->first;
73}
74
75/**
76 * Set an option's weight.

Callers 5

~PathfindingOpenSetMethod · 0.80
removeDiscardedMethod · 0.80
popMethod · 0.80
getTopRaceMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected