Index: trunk/src/extensions/common/matcher/substring_set_matcher.h |
=================================================================== |
--- trunk/src/extensions/common/matcher/substring_set_matcher.h (revision 198804) |
+++ trunk/src/extensions/common/matcher/substring_set_matcher.h (working copy) |
@@ -5,7 +5,6 @@ |
#ifndef EXTENSIONS_COMMON_MATCHER_SUBSTRING_SET_MATCHER_H_ |
#define EXTENSIONS_COMMON_MATCHER_SUBSTRING_SET_MATCHER_H_ |
-#include <limits> |
#include <map> |
#include <set> |
#include <string> |
@@ -81,22 +80,21 @@ |
class AhoCorasickNode { |
public: |
// Key: label of the edge, value: node index in |tree_| of parent class. |
- typedef std::map<char, uint32> Edges; |
+ typedef std::map<char, int> Edges; |
typedef std::set<StringPattern::ID> Matches; |
- static const uint32 kNoSuchEdge = ~0; |
- |
AhoCorasickNode(); |
~AhoCorasickNode(); |
AhoCorasickNode(const AhoCorasickNode& other); |
AhoCorasickNode& operator=(const AhoCorasickNode& other); |
- uint32 GetEdge(char c) const; |
- void SetEdge(char c, uint32 node); |
+ bool HasEdge(char c) const; |
+ int GetEdge(char c) const; |
+ void SetEdge(char c, int node); |
const Edges& edges() const { return edges_; } |
- uint32 failure() const { return failure_; } |
- void set_failure(uint32 failure) { failure_ = failure; } |
+ int failure() const { return failure_; } |
+ void set_failure(int failure) { failure_ = failure; } |
void AddMatch(StringPattern::ID id); |
void AddMatches(const Matches& matches); |
@@ -107,18 +105,14 @@ |
Edges edges_; |
// Node index that failure edge leads to. |
- uint32 failure_; |
+ int failure_; |
// Identifiers of matches. |
Matches matches_; |
}; |
- typedef std::map<StringPattern::ID, const StringPattern*> SubstringPatternMap; |
- typedef std::vector<const StringPattern*> SubstringPatternVector; |
+ void RebuildAhoCorasickTree(); |
- // |sorted_patterns| is a copy of |patterns_| sorted by the pattern string. |
- void RebuildAhoCorasickTree(const SubstringPatternVector& sorted_patterns); |
- |
// Inserts a path for |pattern->pattern()| into the tree and adds |
// |pattern->id()| to the set of matches. Ownership of |pattern| remains with |
// the caller. |
@@ -127,7 +121,9 @@ |
// Set of all registered StringPatterns. Used to regenerate the |
// Aho-Corasick tree in case patterns are registered or unregistered. |
- SubstringPatternMap patterns_; |
+ typedef std::map<StringPattern::ID, const StringPattern*> |
+ SubstringPatternSet; |
+ SubstringPatternSet patterns_; |
// The nodes of a Aho-Corasick tree. |
std::vector<AhoCorasickNode> tree_; |