Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef SETSEQ_H
- #define SETSEQ_H
- template<typename C, typename T = char>
- class SetSequence{
- private:
- C container;
- public:
- //bool operator==(const SetSequence& s);
- typedef typename C::iterator iterator;
- typedef typename C::const_iterator const_iterator;
- typedef typename C::value_type value_type;
- void push_back(value_type const &t)
- {
- bool hasValue = false;
- for(iterator it = container.begin(); it != container.end(); it++)
- {
- if( *it == t ){ hasValue = true; }
- }
- if (!hasValue) { container.push_back(t); }
- }
- void push_front(value_type const &t)
- {
- bool hasValue = false;
- for(iterator it = container.begin(); it != container.end(); it++)
- {
- if( *it == t ){ hasValue = true; }
- }
- if (!hasValue) { container.push_front(t); }
- }
- void set_union(SetSequence const &s){
- for(const_iterator it = s.begin(); it != s.end(); it++){
- push_back( *it );
- }
- }
- unsigned int size() const{return container.size();}
- const T back() const {return container.back();}
- const T& front() const {return container.front();}
- iterator begin(){ return container.begin(); }
- iterator end(){ return container.end(); }
- const_iterator begin() const{ return container.begin(); }
- const_iterator end() const{ return container.end();}
- void erase(T const &t)
- {
- for(iterator it = container.begin(); it != container.end();){
- if(*it == t) { it = container.erase(it);}
- else { it++; }
- }
- }
- unsigned int count(T const &t)
- {
- unsigned int db = 0;
- for(iterator it = container.begin(); it != container.end(); it++){
- if(*it == t){ ++db; }
- }
- return db;
- }
- };
- /*
- template<typename C, typename T = char>
- bool operator==(const SetSequence<C, T>& s)
- {
- return true;
- }*/
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement