我想实现一个TrieNode类,该类包含一组TrieNode指针,并且它的值是一个int。如何定义节点集的比较?
MySetTrieNode.h
class MySetTrieNode {
public:
int character;
std::set<MySetTrieNode *> *nodes;
public:
bool operator<(MySetTrieNode other) const;
};
MySetTrieNode.cpp
MySetTrieNode::MySetTrieNode() {
this->character = -1;
nodes = new std::set<MySetTrieNode *>();
}
bool MySetTrieNode::operator<(const MySetTrieNode other) const {
return this->character < other.character;
}