Advertisement
Guest User

Untitled

a guest
May 24th, 2015
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #ifndef AECONT_H_INCLUDED
  2. #define AECONT_H_INCLUDED
  3.  
  4. #include <list>
  5.  
  6. template<class T>
  7. class alternating_endpoint_container:public std::list<T>
  8. {
  9. public:
  10. void insert(const T &e)
  11. {
  12. if(where==0)
  13. {
  14. this->push_back(e);
  15. where++;
  16. }else
  17. {
  18. this->push_front(e);
  19. where=0;
  20. }
  21. }
  22. const
  23. T at(const int &pos)const
  24. {
  25. typename std::list<T>::const_iterator it=this->begin();
  26. int i=0;
  27. for(int i=0;i<pos;i++)it++;
  28. return *it;
  29. }
  30. /*
  31.  
  32. T at(int pos)
  33. {
  34. typename std::list<T>::const_iterator it=this->begin();
  35. int i=0;
  36. for(int i=0;i<pos;i++)it++;
  37. return *it;
  38. }
  39. */
  40. private:
  41. int where=1;
  42. };
  43.  
  44.  
  45. #endif // AECONT_H_INCLUDED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement