Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef AECONT_H_INCLUDED
- #define AECONT_H_INCLUDED
- #include <list>
- template<class T>
- class alternating_endpoint_container:public std::list<T>
- {
- public:
- void insert(const T &e)
- {
- if(where==0)
- {
- this->push_back(e);
- where++;
- }else
- {
- this->push_front(e);
- where=0;
- }
- }
- const
- T at(const int &pos)const
- {
- typename std::list<T>::const_iterator it=this->begin();
- int i=0;
- for(int i=0;i<pos;i++)it++;
- return *it;
- }
- /*
- T at(int pos)
- {
- typename std::list<T>::const_iterator it=this->begin();
- int i=0;
- for(int i=0;i<pos;i++)it++;
- return *it;
- }
- */
- private:
- int where=1;
- };
- #endif // AECONT_H_INCLUDED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement