diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2009-11-14 16:53:43 +0100 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2009-11-14 16:56:30 +0100 |
commit | e3392e343f7de1eadb12f8080c96be6b65c432e7 (patch) | |
tree | efec505fb8b06af456446c4dadd9c8dc90960d23 /crawl-ref/source/random-weight.h | |
parent | 3f6d4183b36a5056e204b9568909215217c1cf07 (diff) | |
download | crawl-ref-e3392e343f7de1eadb12f8080c96be6b65c432e7.tar.gz crawl-ref-e3392e343f7de1eadb12f8080c96be6b65c432e7.zip |
Document random_choose_weighted.
Diffstat (limited to 'crawl-ref/source/random-weight.h')
-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) { |