COMMON: Added Common::List::front() and back() method (similar to std::list)

svn-id: r40154
This commit is contained in:
Max Horn 2009-04-27 11:11:42 +00:00
parent ed87cbab90
commit 84f0e1d986
2 changed files with 20 additions and 4 deletions

View File

@ -132,6 +132,22 @@ public:
i = erase(i);
}
t_T &front() {
return static_cast<Node *>(_anchor._next)->_data;
}
const t_T &front() const {
return static_cast<Node *>(_anchor._next)->_data;
}
t_T &back() {
return static_cast<Node *>(_anchor._prev)->_data;
}
const t_T &back() const {
return static_cast<Node *>(_anchor._prev)->_data;
}
List<t_T> &operator=(const List<t_T> &list) {
if (this != &list) {

View File

@ -55,19 +55,19 @@ public:
}
T &front() {
return *_impl.begin();
return _impl.front();
}
const T &front() const {
return *_impl.begin();
return _impl.front();
}
T &back() {
return *_impl.reverse_begin();
return _impl.back();
}
const T &back() const {
return *_impl.reverse_begin();
return _impl.back();
}
T pop() {