Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Algorithms Library Toolkit Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Algorithms Library Toolkit
Algorithms Library Toolkit Core
Commits
e6210290
"README.md" did not exist on "44cec280044a9282d67b8aad8d139293fbcc179f"
Commit
e6210290
authored
10 years ago
by
Jan Trávníček
Browse files
Options
Downloads
Patches
Plain Diff
do not throw when manipulating with sets in regexp
parent
250438ff
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
alib2/src/regexp/RegExp.cpp
+5
-9
5 additions, 9 deletions
alib2/src/regexp/RegExp.cpp
alib2/src/regexp/RegExp.h
+2
-2
2 additions, 2 deletions
alib2/src/regexp/RegExp.h
with
7 additions
and
11 deletions
alib2/src/regexp/RegExp.cpp
+
5
−
9
View file @
e6210290
...
@@ -64,7 +64,7 @@ RegExp& RegExp::operator=(const RegExp& other) {
...
@@ -64,7 +64,7 @@ RegExp& RegExp::operator=(const RegExp& other) {
RegExp
&
RegExp
::
operator
=
(
RegExp
&&
other
)
noexcept
{
RegExp
&
RegExp
::
operator
=
(
RegExp
&&
other
)
noexcept
{
std
::
swap
(
this
->
regExp
,
other
.
regExp
);
std
::
swap
(
this
->
regExp
,
other
.
regExp
);
std
::
swap
(
this
->
alphabet
,
other
.
alphabet
);
return
*
this
;
return
*
this
;
}
}
...
@@ -98,10 +98,8 @@ const std::set<alphabet::Symbol>& RegExp::getAlphabet() const {
...
@@ -98,10 +98,8 @@ const std::set<alphabet::Symbol>& RegExp::getAlphabet() const {
return
alphabet
;
return
alphabet
;
}
}
void
RegExp
::
addSymbolToAlphabet
(
const
alphabet
::
Symbol
&
symbol
)
{
bool
RegExp
::
addSymbolToAlphabet
(
const
alphabet
::
Symbol
&
symbol
)
{
std
::
pair
<
std
::
set
<
alphabet
::
Symbol
>::
iterator
,
bool
>
ret
=
alphabet
.
insert
(
symbol
);
return
alphabet
.
insert
(
symbol
).
second
;
if
(
!
ret
.
second
)
throw
alib
::
AlibException
(
"Symbol
\"
"
+
(
std
::
string
)
symbol
+
"
\"
is already in the alphabet."
);
}
}
void
RegExp
::
setAlphabet
(
const
std
::
set
<
alphabet
::
Symbol
>
&
symbols
)
{
void
RegExp
::
setAlphabet
(
const
std
::
set
<
alphabet
::
Symbol
>
&
symbols
)
{
...
@@ -116,13 +114,11 @@ void RegExp::setAlphabet(const std::set<alphabet::Symbol> & symbols) {
...
@@ -116,13 +114,11 @@ void RegExp::setAlphabet(const std::set<alphabet::Symbol> & symbols) {
this
->
alphabet
=
symbols
;
this
->
alphabet
=
symbols
;
}
}
void
RegExp
::
removeSymbolFromAlphabet
(
const
alphabet
::
Symbol
&
symbol
)
{
bool
RegExp
::
removeSymbolFromAlphabet
(
const
alphabet
::
Symbol
&
symbol
)
{
if
(
this
->
regExp
->
testSymbol
(
symbol
))
if
(
this
->
regExp
->
testSymbol
(
symbol
))
throw
alib
::
AlibException
(
"Input symbol
\"
"
+
(
std
::
string
)
symbol
+
"
\"
is used."
);
throw
alib
::
AlibException
(
"Input symbol
\"
"
+
(
std
::
string
)
symbol
+
"
\"
is used."
);
int
removed
=
alphabet
.
erase
(
symbol
);
return
alphabet
.
erase
(
symbol
);
if
(
!
removed
)
throw
alib
::
AlibException
(
"Input symbol
\"
"
+
(
std
::
string
)
symbol
+
"
\"
doesn't exist."
);
}
}
bool
RegExp
::
isEmpty
()
const
{
bool
RegExp
::
isEmpty
()
const
{
...
...
This diff is collapsed.
Click to expand it.
alib2/src/regexp/RegExp.h
+
2
−
2
View file @
e6210290
...
@@ -79,7 +79,7 @@ public:
...
@@ -79,7 +79,7 @@ public:
* Adds symbol to the alphabet available in the regular expression
* Adds symbol to the alphabet available in the regular expression
* @param symbol new symbol added to the alphabet
* @param symbol new symbol added to the alphabet
*/
*/
void
addSymbolToAlphabet(const alphabet::Symbol & symbol);
bool
addSymbolToAlphabet(const alphabet::Symbol & symbol);
/**
/**
* Sets the alphabet of the regular expression
* Sets the alphabet of the regular expression
...
@@ -91,7 +91,7 @@ public:
...
@@ -91,7 +91,7 @@ public:
* Removes symbol from the alphabet of symbol available in the regular expression
* Removes symbol from the alphabet of symbol available in the regular expression
* @param symbol removed symbol from the alphabet
* @param symbol removed symbol from the alphabet
*/
*/
void
removeSymbolFromAlphabet(const alphabet::Symbol & symbol);
bool
removeSymbolFromAlphabet(const alphabet::Symbol & symbol);
/**
/**
* @return true if regexp represents empty language
* @return true if regexp represents empty language
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment