diff --git a/alib/src/regexp/Alternation.cpp b/alib/src/regexp/Alternation.cpp index d5cc96bcb6f53b64d0f46a79bb8623776e6887b4..2bd801d82e6de887b1930000524de75c4f6372e8 100644 --- a/alib/src/regexp/Alternation.cpp +++ b/alib/src/regexp/Alternation.cpp @@ -98,37 +98,6 @@ bool Alternation::operator==(const Alternation& other) const { return true; } -bool Alternation::operator>(const Alternation& other) const { - int thisSize = this->elements.size(); - int otherSize = other.elements.size(); - if(thisSize < otherSize) return false; - if(thisSize > otherSize) return true; - - auto thisIter = this->elements.begin(); - auto otherIter = other.elements.begin(); - for(; thisIter != this->elements.end(); thisIter++, otherIter++) { - if(**thisIter > **otherIter) return true; - } - - return false; -} - -bool Alternation::operator>(const Iteration&) const { - return true; -} - -bool Alternation::operator>(const RegExpSymbol&) const { - return true; -} - -bool Alternation::operator>(const RegExpEpsilon&) const { - return true; -} - -bool Alternation::operator>(const RegExpEmpty&) const { - return true; -} - bool Alternation::containsEmptyString() const { for(const auto& e : getElements()) if(e->containsEmptyString()) diff --git a/alib/src/regexp/Alternation.h b/alib/src/regexp/Alternation.h index 51884d82a13f8d57e6151774ad7f5156fed63e69..3ce18a9049fc30331c39f91ab91f558754a1883b 100644 --- a/alib/src/regexp/Alternation.h +++ b/alib/src/regexp/Alternation.h @@ -50,11 +50,6 @@ public: virtual bool operator<(const Concatenation&) const; virtual bool operator<(const Alternation&) const; virtual bool operator==(const Alternation&) const; - virtual bool operator>(const Alternation&) const; - virtual bool operator>(const Iteration&) const; - virtual bool operator>(const RegExpSymbol&) const; - virtual bool operator>(const RegExpEpsilon&) const; - virtual bool operator>(const RegExpEmpty&) const; /** * @copydoc RegExpElement::containsEmptyString() const diff --git a/alib/src/regexp/Concatenation.cpp b/alib/src/regexp/Concatenation.cpp index a9c8477aad849f897a73024fb331b98589fd1472..0387d454fb5e21f7d06d347e48a40f753a6aceeb 100644 --- a/alib/src/regexp/Concatenation.cpp +++ b/alib/src/regexp/Concatenation.cpp @@ -94,41 +94,6 @@ bool Concatenation::operator==(const Concatenation& other) const { return true; } -bool Concatenation::operator>(const Concatenation& other) const { - int thisSize = this->elements.size(); - int otherSize = other.elements.size(); - if(thisSize < otherSize) return false; - if(thisSize > otherSize) return true; - - auto thisIter = this->elements.begin(); - auto otherIter = other.elements.begin(); - for(; thisIter != this->elements.end(); thisIter++, otherIter++) { - if(**thisIter > **otherIter) return true; - } - - return false; -} - -bool Concatenation::operator>(const Alternation&) const { - return true; -} - -bool Concatenation::operator>(const Iteration&) const { - return true; -} - -bool Concatenation::operator>(const RegExpSymbol&) const { - return true; -} - -bool Concatenation::operator>(const RegExpEpsilon&) const { - return true; -} - -bool Concatenation::operator>(const RegExpEmpty&) const { - return true; -} - bool Concatenation::containsEmptyString() const { for( const auto& e : getElements()) if( ! e->containsEmptyString()) diff --git a/alib/src/regexp/Concatenation.h b/alib/src/regexp/Concatenation.h index f082f9d208aead5fe7a06eef1e22a08963cf87ab..2e4713875fad7ac0aaef1d4a61fd03a4ac0c7583 100644 --- a/alib/src/regexp/Concatenation.h +++ b/alib/src/regexp/Concatenation.h @@ -49,12 +49,6 @@ public: virtual bool operator<(const Concatenation&) const; virtual bool operator==(const Concatenation&) const; - virtual bool operator>(const Concatenation&) const; - virtual bool operator>(const Alternation&) const; - virtual bool operator>(const Iteration&) const; - virtual bool operator>(const RegExpSymbol&) const; - virtual bool operator>(const RegExpEpsilon&) const; - virtual bool operator>(const RegExpEmpty&) const; /** * @copydoc RegExpElement::containsEmptyString() const diff --git a/alib/src/regexp/Iteration.cpp b/alib/src/regexp/Iteration.cpp index 61e38b6f321985fd4bcee64a755e5335d13167e0..85e68a102533aab7f0d9ea8d9b7c689710441ad6 100644 --- a/alib/src/regexp/Iteration.cpp +++ b/alib/src/regexp/Iteration.cpp @@ -93,22 +93,6 @@ bool Iteration::operator==(const Iteration& other) const { return *(this->element) == *(other.element); } -bool Iteration::operator>(const Iteration& other) const { - return *(this->element) > *(other.element); -} - -bool Iteration::operator>(const RegExpSymbol&) const { - return true; -} - -bool Iteration::operator>(const RegExpEpsilon&) const { - return true; -} - -bool Iteration::operator>(const RegExpEmpty&) const { - return true; -} - bool Iteration::containsEmptyString() const { return true; } diff --git a/alib/src/regexp/Iteration.h b/alib/src/regexp/Iteration.h index 49b9e2cb82e3b534b1f7e7beac90212a364b74c5..4bca308eabb4bfdb40e6fca360debc9976648c3d 100644 --- a/alib/src/regexp/Iteration.h +++ b/alib/src/regexp/Iteration.h @@ -56,10 +56,6 @@ public: virtual bool operator<(const Alternation&) const; virtual bool operator<(const Iteration&) const; virtual bool operator==(const Iteration&) const; - virtual bool operator>(const Iteration&) const; - virtual bool operator>(const RegExpSymbol&) const; - virtual bool operator>(const RegExpEpsilon&) const; - virtual bool operator>(const RegExpEmpty&) const; /** * @copydoc RegExpElement::containsEmptyString() const diff --git a/alib/src/regexp/RegExp.cpp b/alib/src/regexp/RegExp.cpp index 895b858ef08d26f048b3a3d1d158570258ec1873..27afc0cb913744b2fcd94073b5ea2d4c9d66aa89 100644 --- a/alib/src/regexp/RegExp.cpp +++ b/alib/src/regexp/RegExp.cpp @@ -92,6 +92,10 @@ bool RegExp::operator<(const RegExp& other) const { return *(this->regExp) < *(other.regExp); } +bool RegExp::operator<=(const RegExp& other) const { + return *(this->regExp) <= *(other.regExp); +} + bool RegExp::operator==(const RegExp& other) const { return *(this->regExp) == *(other.regExp); } @@ -104,4 +108,8 @@ bool RegExp::operator>(const RegExp& other) const { return *(this->regExp) > *(other.regExp); } +bool RegExp::operator>=(const RegExp& other) const { + return *(this->regExp) >= *(other.regExp); +} + } /* namespace regexp */ diff --git a/alib/src/regexp/RegExp.h b/alib/src/regexp/RegExp.h index ebcc518531c33848f405bc315f1dd4e015d47dee..ef21bad4b54a3c9391d41dcc2e373d191ab2fbcc 100644 --- a/alib/src/regexp/RegExp.h +++ b/alib/src/regexp/RegExp.h @@ -78,9 +78,11 @@ public: friend ostream& operator<<(ostream& out, RegExp& regexp); bool operator<(const RegExp&) const; + bool operator<=(const RegExp&) const; bool operator==(const RegExp&) const; bool operator!=(const RegExp&) const; bool operator>(const RegExp&) const; + bool operator>=(const RegExp&) const; }; } /* namespace regexp */ diff --git a/alib/src/regexp/RegExpElement.cpp b/alib/src/regexp/RegExpElement.cpp index 4b1cfb88348cd72b4e19cf86437a2806eb2f259f..fc07c4c1f017c38e277ec1b9717f54ba53d569a3 100644 --- a/alib/src/regexp/RegExpElement.cpp +++ b/alib/src/regexp/RegExpElement.cpp @@ -13,6 +13,14 @@ RegExpElement::~RegExpElement() { } +bool RegExpElement::operator>=(const RegExpElement& other) const { + return !(*this < other); +} + +bool RegExpElement::operator<=(const RegExpElement& other) const { + return !(*this > other); +} + bool RegExpElement::operator!=(const RegExpElement& other) const { return !(*this == other); } @@ -63,34 +71,8 @@ bool RegExpElement::operator==(const RegExpEpsilon& other) const { return false; } - bool RegExpElement::operator==(const RegExpEmpty& other) const { return false; } -bool RegExpElement::operator>(const Concatenation& other) const { - return false; -} - -bool RegExpElement::operator>(const Alternation& other) const { - return false; -} - -bool RegExpElement::operator>(const Iteration& other) const { - return false; -} - -bool RegExpElement::operator>(const RegExpSymbol& other) const { - return false; -} - -bool RegExpElement::operator>(const RegExpEpsilon& other) const { - return false; -} - -bool RegExpElement::operator>(const RegExpEmpty& other) const { - return false; -} - } /* namespace regexp */ - diff --git a/alib/src/regexp/RegExpElement.h b/alib/src/regexp/RegExpElement.h index 206c80759d6a31e8765f0d459935fe47f94fa31f..69421fde011bed11460fac27446cdcd19303d794 100644 --- a/alib/src/regexp/RegExpElement.h +++ b/alib/src/regexp/RegExpElement.h @@ -37,6 +37,8 @@ public: virtual bool operator==(const RegExpElement&) const = 0; virtual bool operator>(const RegExpElement&) const = 0; + virtual bool operator>=(const RegExpElement&) const; + virtual bool operator<=(const RegExpElement&) const; virtual bool operator!=(const RegExpElement&) const; virtual bool operator<(const Concatenation&) const; @@ -53,13 +55,6 @@ public: virtual bool operator==(const RegExpEpsilon&) const; virtual bool operator==(const RegExpEmpty&) const; - virtual bool operator>(const Concatenation&) const; - virtual bool operator>(const Alternation&) const; - virtual bool operator>(const Iteration&) const; - virtual bool operator>(const RegExpSymbol&) const; - virtual bool operator>(const RegExpEpsilon&) const; - virtual bool operator>(const RegExpEmpty&) const; - /** * @return true if this subtree of regexp matches empty string (epsilon) */ diff --git a/alib/src/regexp/RegExpEpsilon.cpp b/alib/src/regexp/RegExpEpsilon.cpp index 8909db8053f0c6d319c775af22cf28484a8cab99..ff8fbb4b1234c3555e751c8d270cc7331743c38a 100644 --- a/alib/src/regexp/RegExpEpsilon.cpp +++ b/alib/src/regexp/RegExpEpsilon.cpp @@ -49,10 +49,6 @@ bool RegExpEpsilon::operator==(const RegExpEpsilon&) const { return true; } -bool RegExpEpsilon::operator>(const RegExpEmpty&) const { - return true; -} - bool RegExpEpsilon::containsEmptyString() const { return true; } diff --git a/alib/src/regexp/RegExpEpsilon.h b/alib/src/regexp/RegExpEpsilon.h index 351df1bde6edecfe2a062e7022d6c45fd1d81f6c..a7dced2eafa80ee1764f7489e1c0f4b9a1264d28 100644 --- a/alib/src/regexp/RegExpEpsilon.h +++ b/alib/src/regexp/RegExpEpsilon.h @@ -37,7 +37,6 @@ public: virtual bool operator<(const Iteration&) const; virtual bool operator<(const RegExpSymbol&) const; virtual bool operator==(const RegExpEpsilon&) const; - virtual bool operator>(const RegExpEmpty&) const; /** * @copydoc RegExpElement::containsEmptyString() const diff --git a/alib/src/regexp/RegExpSymbol.cpp b/alib/src/regexp/RegExpSymbol.cpp index 75a109e77068175c48d6e0fda168d6899900109f..2283563829e9c134f673d8da07db4a8360f3d138 100644 --- a/alib/src/regexp/RegExpSymbol.cpp +++ b/alib/src/regexp/RegExpSymbol.cpp @@ -54,18 +54,6 @@ bool RegExpSymbol::operator==(const RegExpSymbol& other) const { return this->symbol == other.symbol; } -bool RegExpSymbol::operator>(const RegExpSymbol& other) const { - return this->symbol > other.symbol; -} - -bool RegExpSymbol::operator>(const RegExpEpsilon&) const { - return true; -} - -bool RegExpSymbol::operator>(const RegExpEmpty&) const { - return true; -} - bool RegExpSymbol::containsEmptyString() const { return false; } diff --git a/alib/src/regexp/RegExpSymbol.h b/alib/src/regexp/RegExpSymbol.h index 6ea3028565bb4f5806f4a66007d441dfbd04d07d..1c337bc1157e3bcf6939be851da0e6f5eb6381a1 100644 --- a/alib/src/regexp/RegExpSymbol.h +++ b/alib/src/regexp/RegExpSymbol.h @@ -40,9 +40,6 @@ public: virtual bool operator<(const Iteration&) const; virtual bool operator<(const RegExpSymbol&) const; virtual bool operator==(const RegExpSymbol&) const; - virtual bool operator>(const RegExpSymbol&) const; - virtual bool operator>(const RegExpEpsilon&) const; - virtual bool operator>(const RegExpEmpty&) const; /**