diff options
-rw-r--r-- | crawl-ref/source/random-weight.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/crawl-ref/source/random-weight.h b/crawl-ref/source/random-weight.h index 7b9995520f..2c7f8b9bca 100644 --- a/crawl-ref/source/random-weight.h +++ b/crawl-ref/source/random-weight.h @@ -1,6 +1,12 @@ #ifndef RANDOM_WEIGHT_H #define RANDOM_WEIGHT_H +/* + * Weighted choice. + * + * Weights are assumed to be non-negative, but are allowed to be zero. + * Returns NULL if nothing found, i.e., if all weights are zero. + */ template <typename T> T* random_choose_weighted(std::vector<std::pair<T, int> > choices) { |