add DEFINE MIN MACRO

This commit is contained in:
wyy 2014-01-04 17:48:13 +08:00
parent 14aa9168d3
commit 80f9d2ea4c
2 changed files with 4 additions and 3 deletions

View File

@ -3,6 +3,7 @@
#include "MPSegment.hpp" #include "MPSegment.hpp"
#include <cmath> #include <cmath>
#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
namespace CppJieba namespace CppJieba
{ {
@ -109,7 +110,7 @@ namespace CppJieba
} }
} }
keywords.resize(min(topN, wordmap.size())); keywords.resize(MIN(topN, wordmap.size()));
partial_sort_copy(wordmap.begin(), wordmap.end(), keywords.begin(), keywords.end(), _cmp); partial_sort_copy(wordmap.begin(), wordmap.end(), keywords.begin(), keywords.end(), _cmp);
return true; return true;
} }

View File

@ -16,9 +16,9 @@ TEST(SegmentBaseTest, Test1)
uint offset = 0; uint offset = 0;
while(offset < size) while(offset < size)
{ {
uint len; uint len = 0;
const char* t = str + offset; const char* t = str + offset;
int ret = SegmentBase::filterAscii(t, size - offset, len); SegmentBase::filterAscii(t, size - offset, len);
s.assign(t, len); s.assign(t, len);
res.push_back(s); res.push_back(s);
//cout<<s<<","<<ret<<","<<len<<endl; //cout<<s<<","<<ret<<","<<len<<endl;