Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Simox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Leander Singer
Simox
Commits
2dac8480
Commit
2dac8480
authored
4 years ago
by
Rainer Kartmann
Browse files
Options
Downloads
Patches
Plain Diff
Add get_keys() and get_values() for std::map
parent
9c6aa5de
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
SimoxUtility/CMakeLists.txt
+1
-0
1 addition, 0 deletions
SimoxUtility/CMakeLists.txt
SimoxUtility/algorithm.h
+1
-0
1 addition, 0 deletions
SimoxUtility/algorithm.h
SimoxUtility/algorithm/get_map_keys_values.h
+35
-0
35 additions, 0 deletions
SimoxUtility/algorithm/get_map_keys_values.h
with
37 additions
and
0 deletions
SimoxUtility/CMakeLists.txt
+
1
−
0
View file @
2dac8480
...
...
@@ -88,6 +88,7 @@ SET(INCLUDES
algorithm/for_each_if.h
algorithm/apply.hpp
algorithm/get_map_keys_values.h
color/cmaps/colormaps.h
color/cmaps/Named.h
...
...
This diff is collapsed.
Click to expand it.
SimoxUtility/algorithm.h
+
1
−
0
View file @
2dac8480
...
...
@@ -3,3 +3,4 @@
// This file is generated!
#include
"algorithm/for_each_if.h"
#include
"algorithm/get_map_keys_values.h"
This diff is collapsed.
Click to expand it.
SimoxUtility/algorithm/get_map_keys_values.h
0 → 100644
+
35
−
0
View file @
2dac8480
#include
<map>
#include
<vector>
namespace
simox
{
template
<
typename
K
,
typename
V
>
std
::
vector
<
K
>
get_keys
(
const
std
::
map
<
K
,
V
>&
map
)
{
std
::
vector
<
K
>
keys
;
keys
.
reserve
(
map
.
size
());
for
(
const
auto
&
[
k
,
v
]
:
map
)
{
keys
.
push_back
(
k
);
}
return
keys
;
}
template
<
typename
K
,
typename
V
>
std
::
vector
<
V
>
get_values
(
const
std
::
map
<
K
,
V
>&
map
)
{
std
::
vector
<
V
>
values
;
values
.
reserve
(
map
.
size
());
for
(
const
auto
&
[
k
,
v
]
:
map
)
{
values
.
push_back
(
v
);
}
return
values
;
}
}
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