- inline bool addEdge(Node* N) {
- const std::string& Label = N->getLabel();
- return Children.insert(std::make_pair(Label[0], N)).second;
+#if 0
+ inline void dump() {
+ std::cerr << "Node: " << this << "\n"
+ << "Label: " << Label << "\n"
+ << "Children:\n";
+
+ for (NodeVectorIter I = Children.begin(), E = Children.end(); I != E; ++I)
+ std::cerr << (*I)->Label << "\n";
+ }
+#endif
+
+ inline void addEdge(Node* N) {
+ if (Children.empty())
+ Children.push_back(N);
+ else {
+ NodeVectorIter I = std::lower_bound(Children.begin(), Children.end(),
+ N, NodeCmp());
+ // FIXME: no dups are allowed
+ Children.insert(I, N);
+ }
+ }
+
+ inline Node* getEdge(char Id) {
+ Node* fNode = NULL;
+ NodeVectorIter I = std::lower_bound(Children.begin(), Children.end(),
+ Id, NodeCmp());
+ if (I != Children.end() && (*I)->Label[0] == Id)
+ fNode = *I;
+
+ return fNode;
+ }
+
+ inline void setEdge(Node* N) {
+ char Id = N->Label[0];
+ NodeVectorIter I = std::lower_bound(Children.begin(), Children.end(),
+ Id, NodeCmp());
+ assert(I != Children.end() && "Node does not exists!");
+ *I = N;