我正在研究 C++ 并使用 multimap 来存储数据。
struct data
{
char* value1;
char* value2;
data(char* _value1, char* _value2)
{
int len1 = strlen(_value1);
value1 = new char[len1+1];
strcpy(value1,_value1);
int len2 = strlen(_value2);
value2 = new char[len2+2];
strcpy(value2,_value2);
}
~data()
{
delete[] value1;
delete[] value2;
}
}
struct ltstr
{
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) < 0;
}
};
multimap <char*, data*, ltstr> m;
样本输入:
Key Value
ABCD123456 Data_Mining Indent Test Fast Might Must Favor List Myself Janki Jyoti Sepal Petal Catel Katlina Katrina Tesing Must Motor blah blah.
ABCD123456 Datfassaa_Minifasfngf Indesfsant Tfdasest Fast Might Must Favor List My\\fsad\\\self Jfasfsa Katrifasdna Tesinfasfg Must Motor blah blah.
tretD152456 fasdfa fasfsaDfasdfsafata_Mafsfining Infdsdent Tdfsest Fast Might Must Favor List Myself Janki
输入中有 2700 万个条目。输入大小 = 14GB
但我注意到内存消耗达到 56 GB。我可以知道如何减少内存大小吗?