Add more scalar operators for range
This commit is contained in:
parent
ea9d6c175d
commit
aabbf231c5
17
range.cpp
17
range.cpp
@ -95,6 +95,23 @@ range<T>::normalise (T val) const {
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
range<T>&
|
||||
range<T>::operator*= (T val) {
|
||||
min *= val;
|
||||
max *= val;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
range<T>
|
||||
range<T>::operator* (T val) const {
|
||||
return range<T> (min * val, max * val);
|
||||
}
|
||||
|
||||
|
||||
namespace util {
|
||||
template <>
|
||||
double
|
||||
|
13
range.hpp
13
range.hpp
@ -48,9 +48,22 @@ namespace util {
|
||||
|
||||
/// Expand the range to include this value if necessary
|
||||
void expand (T val);
|
||||
|
||||
/// Normalise a number to [0, 1] within the range. Does not check bounds.
|
||||
double normalise (T val) const;
|
||||
|
||||
range& operator*= (T);
|
||||
range operator* (T) const;
|
||||
|
||||
range& operator/= (T);
|
||||
range operator/ (T) const;
|
||||
|
||||
range& operator+= (T);
|
||||
range operator+ (T) const;
|
||||
|
||||
range& operator-= (T);
|
||||
range operator- (T) const;
|
||||
|
||||
/// Return a pseudo-random uniformly distributed value within the range.
|
||||
/// There are no statistical randomness guarantees whatsoever.
|
||||
T random (void) const;
|
||||
|
Loading…
Reference in New Issue
Block a user