summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/random-var.cc
diff options
context:
space:
mode:
authorRaphael Langella <raphael.langella@gmail.com>2012-08-26 22:50:06 +0200
committerRaphael Langella <raphael.langella@gmail.com>2012-08-26 23:06:30 +0200
commit770bcbd1844b97b671d0e47ea8313cdf2c74c5ea (patch)
treee030cf61afce9ca69b74bb38eb73734bf10f633e /crawl-ref/source/random-var.cc
parenta6c16c7f2066c854a01f25e9e6c3d8e44282a638 (diff)
downloadcrawl-ref-770bcbd1844b97b671d0e47ea8313cdf2c74c5ea.tar.gz
crawl-ref-770bcbd1844b97b671d0e47ea8313cdf2c74c5ea.zip
Use std namespace.
I had to rename distance() (in coord.h) to distance2() because it conflicts with the STL function to compare 2 iterators. Not a bad change given how it returns the square of the distance anyway. I also had to rename the message global variable (in message.cc) to buffer. I tried to fix and improve the coding style has much as I could, but I probably missed a few given how huge and tedious it is. I also didn't touch crawl-gdb.py, and the stuff in prebuilt, rltiles/tool and util/levcomp.*, because I have no clue about those.
Diffstat (limited to 'crawl-ref/source/random-var.cc')
-rw-r--r--crawl-ref/source/random-var.cc30
1 files changed, 15 insertions, 15 deletions
diff --git a/crawl-ref/source/random-var.cc b/crawl-ref/source/random-var.cc
index 3cb9814ab0..82d3b87d9a 100644
--- a/crawl-ref/source/random-var.cc
+++ b/crawl-ref/source/random-var.cc
@@ -18,7 +18,7 @@ random_var::random_var(int s, int e, weight_func w)
init();
}
-random_var::random_var(int s, int e, std::vector<int> ws)
+random_var::random_var(int s, int e, vector<int> ws)
: start(s), end(e), weights(ws)
{
ASSERT(weights.size() == static_cast<unsigned int>(end - start));
@@ -105,7 +105,7 @@ random_var operator+(const random_var& x, const random_var& y)
{
const int start = x.min() + y.min();
const int end = x.max() + y.max() + 1;
- std::vector<int> weights(end - start, 0);
+ vector<int> weights(end - start, 0);
for (int vx = x.min(); vx <= x.max(); ++vx)
for (int vy = y.min(); vy <= y.max(); ++vy)
@@ -118,7 +118,7 @@ random_var negate(const random_var& x)
{
const int start = -x.max();
const int end = -x.min() + 1;
- std::vector<int> weights(end - start, 0);
+ vector<int> weights(end - start, 0);
for (int v = x.min(); v <= x.max(); ++v)
weights[-v - start] = x.weight(v);
@@ -128,7 +128,7 @@ random_var negate(const random_var& x)
random_var operator-(const random_var& x, const random_var& y)
{
- return (x + negate(y));
+ return (x + ::negate(y));
}
const random_var& operator+=(random_var& x, const random_var& y)
@@ -147,7 +147,7 @@ random_var operator/(const random_var& x, int d)
{
const int start = x.min() / d;
const int end = x.max() / d + 1;
- std::vector<int> weights(end - start, 0);
+ vector<int> weights(end - start, 0);
for (int v = x.min(); v <= x.max(); ++v)
weights[v / d - start] += x.weight(v);
@@ -159,7 +159,7 @@ random_var div_rand_round(const random_var& x, int d)
{
const int start = x.min() / d;
const int end = (x.max() + d - 1) / d + 1;
- std::vector<int> weights(end - start, 0);
+ vector<int> weights(end - start, 0);
for (int v = x.min(); v <= x.max(); ++v)
{
@@ -174,26 +174,26 @@ random_var div_rand_round(const random_var& x, int d)
random_var rv::max(const random_var& x, const random_var& y)
{
- const int start = std::max(x.min(), y.min());
- const int end = std::max(x.max(), y.max()) + 1;
- std::vector<int> weights(end - start, 0);
+ const int start = ::max(x.min(), y.min());
+ const int end = ::max(x.max(), y.max()) + 1;
+ vector<int> weights(end - start, 0);
for (int vx = x.min(); vx <= x.max(); ++vx)
for (int vy = y.min(); vy <= y.max(); ++vy)
- weights[std::max(vx, vy) - start] += x.weight(vx) * y.weight(vy);
+ weights[::max(vx, vy) - start] += x.weight(vx) * y.weight(vy);
return random_var(start, end, weights);
}
random_var rv::min(const random_var& x, const random_var& y)
{
- const int start = std::min(x.min(), y.min());
- const int end = std::min(x.max(), y.max()) + 1;
- std::vector<int> weights(end - start, 0);
+ const int start = ::min(x.min(), y.min());
+ const int end = ::min(x.max(), y.max()) + 1;
+ vector<int> weights(end - start, 0);
for (int vx = x.min(); vx <= x.max(); ++vx)
for (int vy = y.min(); vy <= y.max(); ++vy)
- weights[std::min(vx, vy) - start] += x.weight(vx) * y.weight(vy);
+ weights[::min(vx, vy) - start] += x.weight(vx) * y.weight(vy);
return random_var(start, end, weights);
}
@@ -210,5 +210,5 @@ random_var rv::roll_dice(int d, int n)
random_var rv::random2(int n)
{
- return random_var(0, std::max(n, 1));
+ return random_var(0, max(n, 1));
}