aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMax Horn2009-01-21 02:23:09 +0000
committerMax Horn2009-01-21 02:23:09 +0000
commit53cd1361c503fded70b9d1636c8dc4d6e54834e0 (patch)
tree7d729476ec683aa1da41291ea0f2cae954aa03c8 /common
parentb7f7a8c660a0a16addb84101f2b594eb4a0ac6e1 (diff)
downloadscummvm-rg350-53cd1361c503fded70b9d1636c8dc4d6e54834e0.tar.gz
scummvm-rg350-53cd1361c503fded70b9d1636c8dc4d6e54834e0.tar.bz2
scummvm-rg350-53cd1361c503fded70b9d1636c8dc4d6e54834e0.zip
Made Common::Stack return refs, thus ensuring that it matches exactly the behavior of FixedStack; added unit tests
svn-id: r35974
Diffstat (limited to 'common')
-rw-r--r--common/stack.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/common/stack.h b/common/stack.h
index 238d0f6433..e20e81028d 100644
--- a/common/stack.h
+++ b/common/stack.h
@@ -102,7 +102,11 @@ public:
void push(const T &x) {
_stack.push_back(x);
}
- T top() const {
+ T &top() {
+ const int s = size();
+ return _stack[s - 1];
+ }
+ const T &top() const {
const int s = size();
return _stack[s - 1];
}
@@ -114,7 +118,10 @@ public:
int size() const {
return _stack.size();
}
- T operator[](int i) {
+ T &operator[](int i) {
+ return _stack[i];
+ }
+ const T &operator[](int i) const {
return _stack[i];
}
};