1. QSet<T> 只去重不排序, T必须实现 operator==() 和 全局qHash()
2. set<T> 即去重又排序
3. QSet<T>比set<T>速度快,占用空间多
示例:
class CPoint
{
public:
CPoint(short xx = 0, short yy = 0)
{
x = xx;
y = yy;
}
int keyValue() const
{
return MAKELONG(x, y);
}
bool operator==(const CPoint& pt) const
{
return (x == pt.x && y == pt.y);
}
bool operator<(const CPoint& pt) const
{
return keyValue() < pt.keyValue();
}
short x, y;
};
inline uint qHash(const CPoint key){return key.keyValue();}
void main()
{
QSet<CPoint> vv;
vv << CPoint(11, 22);
}