mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-17 18:54:48 +00:00
auxiliary function atmod
This commit is contained in:
parent
b808d78e7f
commit
6aed2c58e8
12
hyper.h
12
hyper.h
@ -884,6 +884,18 @@ const typename Map::mapped_type *at_or_null(const Map& map, const Key& key) {
|
|||||||
return (it == map.end()) ? nullptr : &it->second;
|
return (it == map.end()) ? nullptr : &it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int gmod(int i, int j);
|
||||||
|
|
||||||
|
// vector::at(i) modulo its size (const version)
|
||||||
|
template<class T> const T& atmod(const vector<T>& container, int index) {
|
||||||
|
return container[gmod(index, isize(container))];
|
||||||
|
}
|
||||||
|
|
||||||
|
// vector::at(i) modulo its size (non-const version)
|
||||||
|
template<class T> T& atmod(vector<T>& container, int index) {
|
||||||
|
return container[gmod(index, isize(container))];
|
||||||
|
}
|
||||||
|
|
||||||
namespace daily {
|
namespace daily {
|
||||||
extern bool on;
|
extern bool on;
|
||||||
extern int daily_id;
|
extern int daily_id;
|
||||||
|
Loading…
Reference in New Issue
Block a user