Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef AECONT_H
- #define AECONT_H
- #include <vector>
- #include <algorithm>
- template <typename T>
- class alternating_endpoint_container: public std::vector<T>{
- private:
- typedef std::vector<T> base;
- bool l = true;
- public:
- alternating_endpoint_container(): base(){
- }
- template< class Iter >
- alternating_endpoint_container( Iter first, Iter last ): base(){
- std::for_each( first, last, std::bind1st( std::mem_fun( &alternating_endpoint_container::insert ), this) );
- }
- void insert( T a ){
- ( ( l = !l ) )?( base::insert( base::end(), a ) ):( base::insert( base::begin(), a ) );
- }
- void erase(){
- ( ( l = !l ) )?( base::erase( base::begin() ) ):( base::erase( base::end() - 1 ) );
- }
- };
- #endif // AECONT_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement