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
e91180e3
Commit
e91180e3
authored
6 years ago
by
Jan Trávníček
Browse files
Options
Downloads
Patches
Plain Diff
add set_symmetric_difference with two destinations
parent
cfbbf789
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
alib2common/src/core/components/setComponents.hpp
+1
-2
1 addition, 2 deletions
alib2common/src/core/components/setComponents.hpp
alib2std/src/extensions/algorithm.hpp
+50
-0
50 additions, 0 deletions
alib2std/src/extensions/algorithm.hpp
with
51 additions
and
2 deletions
alib2common/src/core/components/setComponents.hpp
+
1
−
2
View file @
e91180e3
...
@@ -149,8 +149,7 @@ public:
...
@@ -149,8 +149,7 @@ public:
*
CommonException
if
one
of
the
added
elements
is
not
available
in
context
of
datatype
where
the
set
is
used
*
CommonException
if
one
of
the
added
elements
is
not
available
in
context
of
datatype
where
the
set
is
used
*/
*/
void
set
(
SetComponentType
data
)
{
void
set
(
SetComponentType
data
)
{
std
::
set_difference
(
m_data
.
begin
(
),
m_data
.
end
(
),
data
.
begin
(
),
data
.
end
(
),
ext
::
make_callback_iterator
<
const
ComponentType
&
>
(
std
::
bind
(
&
SetComponent
::
checkRemove
,
this
,
std
::
placeholders
::
_1
)
)
);
ext
::
set_symmetric_difference
(
m_data
.
begin
(
),
m_data
.
end
(
),
data
.
begin
(
),
data
.
end
(
),
ext
::
make_callback_iterator
<
const
ComponentType
&
>
(
std
::
bind
(
&
SetComponent
::
checkRemove
,
this
,
std
::
placeholders
::
_1
)
),
ext
::
make_callback_iterator
<
const
ComponentType
&
>
(
std
::
bind
(
&
SetComponent
::
checkAdd
,
this
,
std
::
placeholders
::
_1
)
)
);
std
::
set_difference
(
data
.
begin
(
),
data
.
end
(
),
m_data
.
begin
(
),
m_data
.
end
(
),
ext
::
make_callback_iterator
<
const
ComponentType
&
>
(
std
::
bind
(
&
SetComponent
::
checkAdd
,
this
,
std
::
placeholders
::
_1
)
)
);
m_data
=
std
::
move
(
data
);
m_data
=
std
::
move
(
data
);
}
}
...
...
This diff is collapsed.
Click to expand it.
alib2std/src/extensions/algorithm.hpp
+
50
−
0
View file @
e91180e3
...
@@ -80,6 +80,56 @@ bool excludes(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2)
...
@@ -80,6 +80,56 @@ bool excludes(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2)
return
excludes
(
first1
,
last1
,
first2
,
last2
,
std
::
less
<
decltype
(
*
first1
)
>
());
return
excludes
(
first1
,
last1
,
first2
,
last2
,
std
::
less
<
decltype
(
*
first1
)
>
());
}
}
/**
*
\
brief
*
Constructs
sorted
ranges
beginning
in
the
location
pointed
by
result1
and
result2
with
the
set
differences
of
the
two
sorted
ranges
[
first1
,
last1
)
and
[
first2
,
last2
).
*
*
The
symmetric
difference
of
two
sets
is
formed
by
the
elements
that
are
present
in
one
of
the
sets
,
but
not
in
the
other
.
The
result1
and
result2
are
each
representing
half
of
the
symmetric
difference
,
i
.
e
.
each
being
a
set
difference
of
the
first
range
to
the
second
and
of
the
second
range
to
the
first
.
Among
the
equivalent
elements
in
each
range
,
those
discarded
are
those
that
appear
before
in
the
existent
order
before
the
call
.
The
existing
order
is
also
preserved
for
the
copied
elements
.
*
*
The
elements
are
compared
using
comp
callback
.
Two
elements
,
a
and
b
are
considered
equivalent
if
(
!
comp
(
a
,
b
)
&&
!
comp
(
b
,
a
)).
*
*
The
elements
in
the
ranges
shall
already
be
ordered
according
to
this
same
criterion
(
operator
<
or
comp
).
The
resulting
range
is
also
sorted
according
to
this
.
*/
template
<
class
InputIterator1
,
class
InputIterator2
,
class
OutputIterator1
,
class
OutputIterator2
,
class
Compare
>
void
set_symmetric_difference
(
InputIterator1
first1
,
InputIterator1
last1
,
InputIterator2
first2
,
InputIterator2
last2
,
OutputIterator1
result1
,
OutputIterator2
result2
,
Compare
comp
)
{
while
(
first1
!=
last1
&&
first2
!=
last2
)
{
if
(
comp
(
*
first1
,
*
first2
)
)
{
*
result1
=
*
first1
;
++
result1
;
++
first1
;
}
else
if
(
comp
(
*
first2
,
*
first1
)
)
{
*
result2
=
*
first2
;
++
result2
;
++
first2
;
}
else
{
++
first1
;
++
first2
;
}
}
if
(
first1
==
last1
)
{
std
::
copy
(
first2
,
last2
,
result2
);
}
if
(
first2
==
last2
)
{
std
::
copy
(
first1
,
last1
,
result1
);
}
}
/**
*
\
brief
*
Constructs
sorted
ranges
beginning
in
the
location
pointed
by
result1
and
result2
with
the
set
differences
of
the
two
sorted
ranges
[
first1
,
last1
)
and
[
first2
,
last2
).
*
*
The
symmetric
difference
of
two
sets
is
formed
by
the
elements
that
are
present
in
one
of
the
sets
,
but
not
in
the
other
.
The
result1
and
result2
are
each
representing
half
of
the
symmetric
difference
,
i
.
e
.
each
being
a
set
difference
of
the
first
range
to
the
second
and
of
the
second
range
to
the
first
.
Among
the
equivalent
elements
in
each
range
,
those
discarded
are
those
that
appear
before
in
the
existent
order
before
the
call
.
The
existing
order
is
also
preserved
for
the
copied
elements
.
*
*
The
elements
are
compared
using
operator
<
.
Two
elements
,
a
and
b
are
considered
equivalent
if
(
!
(
a
<
b
)
&&
!
(
b
<
a
)).
*
*
The
elements
in
the
ranges
shall
already
be
ordered
according
to
this
same
criterion
(
operator
<
or
comp
).
The
resulting
range
is
also
sorted
according
to
this
.
*/
template
<
class
InputIterator1
,
class
InputIterator2
,
class
OutputIterator1
,
class
OutputIterator2
>
void
set_symmetric_difference
(
InputIterator1
first1
,
InputIterator1
last1
,
InputIterator2
first2
,
InputIterator2
last2
,
OutputIterator1
result1
,
OutputIterator2
result2
)
{
set_symmetric_difference
(
first1
,
last1
,
first2
,
last2
,
result1
,
result2
,
std
::
less
<
decltype
(
*
first1
)
>
(
)
);
}
/**
/**
*
\
brief
*
\
brief
*
In
container
tranformation
of
all
elements
according
to
the
\
p
tranform
.
*
In
container
tranformation
of
all
elements
according
to
the
\
p
tranform
.
...
...
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