当我将字符串对象存储到 std::map 中时
std::map<std::string, SomeOtherData> map;
字符串将如何存储?我了解到 std::map 通常被实现为红黑树,但如何将字符串存储在那里?作为一个 trie?
最佳答案
如果 trie 你的意思是每个节点一个字符的实现 - 答案是否定的,它存储在每个节点的 std::string 中,因此如果你打算使用 std::strings 作为键,你可以查看 Ternary Trie (据我所知,由 Sedgewick 提议)
关于c++ - map 中的字符串是如何存储的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30668199/