Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WCCL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Analysers
WCCL
Commits
fc92660c
Commit
fc92660c
authored
Nov 9, 2010
by
Adam Wardyński
Browse files
Options
Downloads
Patches
Plain Diff
equals, is_subset_of and intersects for StrSet, changing its to_raw_string to match spec in parser
parent
02c08af5
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
libwccl/values/strset.cpp
+37
-6
37 additions, 6 deletions
libwccl/values/strset.cpp
libwccl/values/strset.h
+4
-11
4 additions, 11 deletions
libwccl/values/strset.h
with
41 additions
and
17 deletions
libwccl/values/strset.cpp
+
37
−
6
View file @
fc92660c
...
...
@@ -11,15 +11,46 @@ const char* StrSet::type_name = "StrSet";
std
::
string
StrSet
::
to_raw_string
()
const
{
std
::
stringstream
ss
;
ss
<<
"{"
;
bool
comma
=
false
;
foreach
(
const
UnicodeString
&
u
,
set_
)
{
if
(
comma
)
{
ss
<<
"["
;
set_t
::
const_iterator
it
=
set_
.
begin
();
while
(
it
!=
set_
.
end
())
{
ss
<<
'\"'
<<
PwrNlp
::
to_utf8
(
*
it
)
<<
'\"'
;
//TODO escaping
if
(
++
it
!=
set_
.
end
())
{
ss
<<
", "
;
}
ss
<<
'\"'
<<
PwrNlp
::
to_utf8
(
u
)
<<
'\"'
;
//TODO escaping
}
ss
<<
"]"
;
return
ss
.
str
();
}
bool
StrSet
::
intersects
(
const
StrSet
&
other
)
const
{
if
(
empty
()
||
other
.
empty
())
{
return
false
;
}
//we just want to check if there is an intersection, no
//need to actually compute it to check if it's empty.
//doing it like below sounds faster than, say, sorting
//the sets and using set_intersection
const
set_t
&
smaller
=
size
()
<
other
.
size
()
?
set_
:
other
.
set_
;
const
set_t
&
bigger
=
size
()
<
other
.
size
()
?
other
.
set_
:
set_
;
foreach
(
const
UnicodeString
&
u
,
smaller
)
{
if
(
bigger
.
find
(
u
)
!=
bigger
.
end
())
{
return
true
;
}
}
return
false
;
}
bool
StrSet
::
is_subset_of
(
const
StrSet
&
other
)
const
{
if
(
empty
()
||
size
()
>
other
.
size
())
{
return
false
;
}
foreach
(
const
UnicodeString
&
u
,
set_
)
{
if
(
other
.
set_
.
find
(
u
)
==
other
.
set_
.
end
())
{
return
false
;
}
}
return
true
;
}
}
/* end ns Wccl */
This diff is collapsed.
Click to expand it.
libwccl/values/strset.h
+
4
−
11
View file @
fc92660c
...
...
@@ -56,19 +56,12 @@ public:
return
set_
.
empty
();
}
bool
is_subset_of
(
const
StrSet
&
/*set*/
)
const
{
//TODO: implement this
return
false
;
}
bool
is_subset_of
(
const
StrSet
&
other
)
const
;
bool
intersects
(
const
StrSet
&
/*set*/
)
const
{
//TODO: implement this
return
false
;
}
bool
intersects
(
const
StrSet
&
other
)
const
;
bool
equals
(
const
StrSet
&
/*set*/
)
const
{
//TODO: implement this
return
false
;
bool
equals
(
const
StrSet
&
other
)
const
{
return
set_
==
other
.
set_
;
}
/// Value override
...
...
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