set_helper

//
// Created by herohlc  on 2017/11/26.
//

#ifndef SET_HELPER_H_
#define SET_HELPER_H_

#include 

#include 
#include 
#include 

using std::cout;
using std::endl;
using std::set;
using std::multiset;

template 
class StatisticSet{
public:
    StatisticSet(){}

    void add(T item) {
        statistic_set_.insert(item);
        history_set_.insert(item);

        cout << statistic_set_.count(item) << endl;
    }

    void del(T item) {
        cout << statistic_set_.count(item) << endl;
        statistic_set_.erase(item);
    }

    void ask(T item) const {
        cout << ((history_set_.find(item) != history_set_.end())? 1 : 0 ) << " " << statistic_set_.count(item) << endl;
    }

    void test() const{
        cout << "--------------------------" << endl;
        for(auto itr : statistic_set_){
            cout << itr << endl;
        }
        cout << "--------------------------" << endl;
    }

private:
    StatisticSet( const StatisticSet&) {}
    StatisticSet& operator = (const StatisticSet&){}

private:
    set      history_set_;
    multiset statistic_set_;

};

#endif // SET_HELPER_H_

你可能感兴趣的:(set_helper)