IAP GITLAB
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
corsika
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pranav Sampathkumar
corsika
Commits
f7de1b85
"git@gitlab.iap.kit.edu:pranav/corsika.git" did not exist on "ff87800ea3da93d370089c9e441641f850d986eb"
Commit
f7de1b85
authored
6 years ago
by
Maximilian Reininghaus
Browse files
Options
Downloads
Patches
Plain Diff
added walk() to traverse the tree
parent
bcc387b1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Environment/VolumeTreeNode.h
+20
-0
20 additions, 0 deletions
Environment/VolumeTreeNode.h
with
20 additions
and
0 deletions
Environment/VolumeTreeNode.h
+
20
−
0
View file @
f7de1b85
...
...
@@ -66,6 +66,24 @@ namespace corsika::environment {
}
}
/**
* Traverses the VolumeTree pre- or post-order and calls the functor \p func for each
* node. \p func takes a reference to VolumeTreeNode as argument. The return value \p
* func is ignored.
*/
template
<
typename
TCallable
,
bool
preorder
=
true
>
void
walk
(
TCallable
func
)
{
if
constexpr
(
preorder
)
{
func
(
*
this
);
std
::
for_each
(
fChildNodes
.
begin
(),
fChildNodes
.
end
(),
[
&
](
auto
&
v
)
{
v
->
walk
(
func
);
});
}
else
{
std
::
for_each
(
fChildNodes
.
begin
(),
fChildNodes
.
end
(),
[
&
](
auto
&
v
)
{
v
->
walk
(
func
);
});
t
(
*
this
);
}
}
void
AddChild
(
VTNUPtr
pChild
)
{
pChild
->
fParentNode
=
this
;
fChildNodes
.
push_back
(
std
::
move
(
pChild
));
...
...
@@ -88,6 +106,8 @@ namespace corsika::environment {
auto
const
&
GetModelProperties
()
const
{
return
*
fModelProperties
;
}
IMPSharedPtr
GetModelPropertiesPtr
()
const
{
return
fModelProperties
;
}
template
<
typename
TModelProperties
,
typename
...
Args
>
auto
SetModelProperties
(
Args
&&
...
args
)
{
static_assert
(
std
::
is_base_of_v
<
IModelProperties
,
TModelProperties
>
,
...
...
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