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:
- bool l = true;
- public:
- alternating_endpoint_container():std::vector<T>(){
- }
- template< class Iter >
- alternating_endpoint_container( Iter first, Iter last ):std::vector<T>(){
- std::for_each( first, last, std::bind1st( std::mem_fun( &alternating_endpoint_container::insert ), this) );
- }
- void insert( T a ){
- ( ( l = !l ) )?( std::vector<T>::insert( std::vector<T>::end(), a ) ):( std::vector<T>::insert( std::vector<T>::begin(), a ) );
- }
- void erase(){
- ( ( l = !l ) )?( std::vector<T>::erase( std::vector<T>::begin() ) ):( std::vector<T>::erase( std::vector<T>::end() - 1 ) );
- }
- };
- #endif // AECONT_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement