Compare contents in LexerATNConfig::operator==

This commit is contained in:
Nathan Burles 2016-08-01 16:31:48 +01:00
parent 903fa473c5
commit 739bf3a756
3 changed files with 9 additions and 1 deletions

View File

@ -89,10 +89,13 @@ size_t LexerATNConfig::hashCode() const {
bool LexerATNConfig::operator == (const LexerATNConfig& other) const
{
if (this == &other)
return true;
if (_passedThroughNonGreedyDecision != other._passedThroughNonGreedyDecision)
return false;
if (_lexerActionExecutor != other._lexerActionExecutor) {
if (_lexerActionExecutor != other._lexerActionExecutor && (_lexerActionExecutor != nullptr && *_lexerActionExecutor != *(other._lexerActionExecutor))) {
return false;
}

View File

@ -115,6 +115,10 @@ bool LexerActionExecutor::operator == (const LexerActionExecutor &obj) const {
return _hashCode == obj._hashCode && Arrays::equals(_lexerActions, obj._lexerActions);
}
bool LexerActionExecutor::operator != (const LexerActionExecutor &obj) const {
return !operator==(obj);
}
size_t LexerActionExecutor::generateHashCode() const {
size_t hash = MurmurHash::initialize();
for (auto lexerAction : _lexerActions) {

View File

@ -125,6 +125,7 @@ namespace atn {
virtual size_t hashCode() const;
virtual bool operator == (const LexerActionExecutor &obj) const;
virtual bool operator != (const LexerActionExecutor &obj) const;
private:
const std::vector<Ref<LexerAction>> _lexerActions;