MCPcopy Create free account
hub / github.com/DFHack/dfhack / random_index

Function random_index

library/include/MiscUtils.h:183–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181
182template <typename FT>
183int random_index(const std::vector<FT>& vec)
184{
185 if (vec.empty())
186 return -1;
187 else if (vec.size() == 1)
188 return 0;
189
190 return random_int(vec.size());
191}
192
193template<typename FT, typename KT>
194inline bool vector_contains(const std::vector<FT> &vec, KT key)

Callers 1

vector_get_randomFunction · 0.85

Calls 3

random_intFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected