stxxl :: map에서 std :: string을 키로 사용하려고합니다.10-100 정도의 작은 문자열에 삽입해도 문제가 없습니다. 그러나 그것에 약 100000 문자열을 삽입하는 동안 세그먼트 오류가 발생하고 있습니다. 여기에서stxxl :: map에서 std :: string을 키로 사용하는 방법
struct CompareGreaterString {
bool operator() (const std::string& a, const std::string& b) const {
return a > b;
}
static std::string max_value() {
return "";
}
};
// template parameter <KeyType, DataType, CompareType, RawNodeSize, RawLeafSize, PDAllocStrategy (optional)>
typedef stxxl::map<std::string, unsigned int, CompareGreaterString, DATA_NODE_BLOCK_SIZE, DATA_LEAF_BLOCK_SIZE> name_map;
name_map strMap((name_map::node_block_type::raw_size)*3, (name_map::leaf_block_type::raw_size)*3);
for (unsigned int i = 0; i < 1000000; i++) { /// Inserting 1 million strings
std::stringstream strStream;
strStream << (i);
Console::println("Inserting: " + strStream.str());
strMap[strStream.str()]=i;
}
은 내가 문자열의 많은 수를 삽입 할 수없는 나는 이유를 식별 할 수없는 나는 다음과 같이
코드입니다. "1377"을 삽입하는 동안 정확히 세그먼테이션 오류가 발생합니다. 또한 정수로 임의의 숫자를 추가 할 수 있습니다. 문자열의 가변 크기가 이러한 문제를 일으킬 수 있다고 생각합니다.
또한 max_value
문자열에 대해 반환 할 내용을 이해할 수 없습니다. 간단히 빈 문자열을 반환했습니다. documentation에 따르면
알기 힘듭니다. segfaults가있는 정확한 행과 주변의 코드를 제공해야 할 수도 있습니다. stxxl 라이브러리에서 추정합니다. – Yirkha