diff options
author | Adam Borowski <kilobyte@angband.pl> | 2011-06-04 03:03:02 +0200 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2011-06-04 14:29:26 +0200 |
commit | 662a84ac03691a43f36464e45cd6d6f88ba101fb (patch) | |
tree | e64ee0fe608972582da55a9729de936dabe99509 /crawl-ref/source/items.h | |
parent | 3905aef836a1d2c33550a5fa5ee2dd9846994b8e (diff) | |
download | crawl-ref-662a84ac03691a43f36464e45cd6d6f88ba101fb.tar.gz crawl-ref-662a84ac03691a43f36464e45cd6d6f88ba101fb.zip |
Gut and parcel out most of stuff.cc
Diffstat (limited to 'crawl-ref/source/items.h')
-rw-r--r-- | crawl-ref/source/items.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/crawl-ref/source/items.h b/crawl-ref/source/items.h index 036ea5924c..4fa1b9b753 100644 --- a/crawl-ref/source/items.h +++ b/crawl-ref/source/items.h @@ -149,4 +149,26 @@ void move_items(const coord_def r, const coord_def p); // Returns the Orb's position on the ground, or origin() coord_def orb_position(); +// stack_iterator guarantees validity so long as you don't manually +// mess with item_def.link: i.e., you can kill the item you're +// examining but you can't kill the item linked to it. +class stack_iterator : public std::iterator<std::forward_iterator_tag, + item_def> +{ +public: + explicit stack_iterator(const coord_def& pos, bool accessible = false); + explicit stack_iterator(int start_link); + + operator bool() const; + item_def& operator *() const; + item_def* operator->() const; + int link() const; + + const stack_iterator& operator ++ (); + stack_iterator operator ++ (int); +private: + int cur_link; + int next_link; +}; + #endif |