summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/coordit.h
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2013-11-25 04:55:59 +0100
committerAdam Borowski <kilobyte@angband.pl>2013-11-25 05:11:38 +0100
commita37dd589bb18013b3ad588c2df7409553cb33935 (patch)
tree66231734aacd3f21016cca81075e673167f70ed3 /crawl-ref/source/coordit.h
parent24c2e89fad680da9e98b9a6b998a060852a8b9e0 (diff)
downloadcrawl-ref-a37dd589bb18013b3ad588c2df7409553cb33935.tar.gz
crawl-ref-a37dd589bb18013b3ad588c2df7409553cb33935.zip
Implement adjacent_iterator on its own, rather than via radius_iterator.
This hardly speeds up things, which I did not know as profile runs did not help to tell these two apart and it turns out adjacent_iterator is not that prominent... but hey, a 0.1% speedup for two pages of code might still be better committed than not. This speedup might disappear when I get around to the actual rewrite of radius_iterator, though.
Diffstat (limited to 'crawl-ref/source/coordit.h')
-rw-r--r--crawl-ref/source/coordit.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/crawl-ref/source/coordit.h b/crawl-ref/source/coordit.h
index 1fa0707734..d20b8d295f 100644
--- a/crawl-ref/source/coordit.h
+++ b/crawl-ref/source/coordit.h
@@ -101,12 +101,22 @@ private:
coord_def current; // storage for operator->
};
-class adjacent_iterator : public radius_iterator
+class adjacent_iterator : public iterator<forward_iterator_tag, coord_def>
{
public:
- explicit adjacent_iterator(const coord_def& pos,
- bool _exclude_center = true) :
- radius_iterator(pos, 1, C_ROUND, _exclude_center) {}
+ adjacent_iterator(const coord_def pos, bool _exclude_center = true)
+ : center(pos), i(_exclude_center ? 8 : 9) {++(*this);};
+
+ operator bool() const PURE;
+ coord_def operator *() const PURE;
+ const coord_def *operator->() const PURE;
+
+ void operator ++ ();
+ void operator ++ (int);
+private:
+ coord_def center;
+ coord_def val;
+ int i;
};
class orth_adjacent_iterator : public radius_iterator