templ 自用

来源:互联网 发布:coc蛮王升级数据表格 编辑:程序博客网 时间:2024/05/16 19:41
template <typename T>
class NameComparator
{
public:
    inline bool operator()(const T* s1, const T* s2) const {
        return s1->getName() < s2->getName();
    }
};


class IdComparator
{
public:
    inline bool operator()(const NetlistObj* s1, const NetlistObj* s2) const {
        return s1->getId() < s2->getId();
    }
};


template<typename K, typename T, typename Compare>
class HalfKeySet : public std::set<T*, Compare >
{
public:
    // std::set<T*, Compare, std::allocator<T*> >::const_iterator;
    typedef typename std::set<T*, Compare>::const_iterator const_iterator;
    typedef typename std::set<T*, Compare >::iterator iterator;
    typedef SetIterator<T*, Compare> GeneralIterator;


    using std::set<T*, Compare >::find;
    const_iterator find(const K& name) {
        T key(name);
        return std::set<T*, Compare >::find(&key);
    }


};
0 0
原创粉丝点击