2017-07-15 10:08:43 +08:00
|
|
|
class KEY_SIZE_VALUE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
unsigned key, size, value;
|
|
|
|
KEY_SIZE_VALUE(unsigned _key = 0, unsigned _size = 0, unsigned _value = 0) : key(_key), size(_size), value(_value) {}
|
|
|
|
bool operator < (const KEY_SIZE_VALUE& b) const
|
|
|
|
{
|
|
|
|
return value > b.value;
|
|
|
|
}
|
|
|
|
bool operator > (const KEY_SIZE_VALUE& b) const
|
|
|
|
{
|
|
|
|
return value < b.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class Longlist_inMem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int key;
|
|
|
|
unsigned _len;
|
|
|
|
char* _str;
|
|
|
|
Longlist_inMem()
|
|
|
|
{
|
|
|
|
key = -1;
|
|
|
|
_len = 0;
|
|
|
|
_str = NULL;
|
|
|
|
}
|
2017-10-09 20:06:57 +08:00
|
|
|
void free()
|
2017-07-15 10:08:43 +08:00
|
|
|
{
|
2017-07-17 14:04:35 +08:00
|
|
|
if(_str != NULL)
|
|
|
|
{
|
|
|
|
delete [] _str;
|
|
|
|
_str = NULL;
|
|
|
|
}
|
2017-10-09 20:06:57 +08:00
|
|
|
key = -1;
|
|
|
|
_len = 0;
|
2017-07-15 10:08:43 +08:00
|
|
|
}
|
|
|
|
};
|
2017-08-02 23:21:36 +08:00
|
|
|
|
2017-10-09 20:06:57 +08:00
|
|
|
|
2017-08-02 23:21:36 +08:00
|
|
|
template <unsigned mod>
|
|
|
|
class CmpByMod
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool operator () (const KEY_SIZE_VALUE& a, const KEY_SIZE_VALUE& b)
|
|
|
|
{
|
|
|
|
return (a.key % mod) > (b.key % mod);
|
|
|
|
}
|
|
|
|
};
|