Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
adt2amas
Manage
Activity
Members
Labels
Plan
Issues
9
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PARTIES
tools
adt2amas
Commits
85beebca
Commit
85beebca
authored
6 years ago
by
Giann Karlo Aguirre Samboní
Browse files
Options
Downloads
Patches
Plain Diff
Get_info method in Nodes implemented
parent
be817d99
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
src/adt2amas.cpp
+3
-0
3 additions, 0 deletions
src/adt2amas.cpp
src/tree_node.cpp
+36
-0
36 additions, 0 deletions
src/tree_node.cpp
src/tree_node.hpp
+3
-11
3 additions, 11 deletions
src/tree_node.hpp
with
42 additions
and
11 deletions
src/adt2amas.cpp
+
3
−
0
View file @
85beebca
...
...
@@ -66,6 +66,9 @@ int main(){
std::cout << *it << ' ';
} */
std
::
cout
<<
endl
;
cout
<<
node_six
->
get_parents
()
<<
endl
;
cout
<<
node_six
->
get_children
()
<<
endl
;
cout
<<
node_six
->
get_info
()
<<
endl
;
/*tree->preorder_print();
tree->inorder_print();
tree->postorder_print();
...
...
This diff is collapsed.
Click to expand it.
src/tree_node.cpp
+
36
−
0
View file @
85beebca
...
...
@@ -116,5 +116,41 @@ void TreeNode::set_next_sibling (TreeNode *next_sibling){
this
->
next_sibling_
=
next_sibling
;
}
/* Other methods */
string
TreeNode
::
get_parents
(){
string
parents
=
""
;
TreeNode
*
tmp_node
=
new
TreeNode
();
tmp_node
=
this
->
first_parent_
;
while
(
tmp_node
!=
nullptr
){
tmp_node
->
next_pibling_
==
nullptr
?
parents
+=
to_string
(
tmp_node
->
id
)
:
parents
+=
to_string
(
tmp_node
->
id
)
+
", "
;
tmp_node
=
tmp_node
->
next_pibling_
;
}
return
parents
;
}
string
TreeNode
::
get_children
(){
string
children
=
""
;
TreeNode
*
tmp_node
=
new
TreeNode
();
tmp_node
=
this
->
first_child_
;
while
(
tmp_node
!=
nullptr
){
tmp_node
->
next_sibling_
==
nullptr
?
children
+=
to_string
(
tmp_node
->
id
)
:
children
+=
to_string
(
tmp_node
->
id
)
+
", "
;
tmp_node
=
tmp_node
->
next_sibling_
;
}
return
children
;
}
string
TreeNode
::
get_info
(){
string
info_node
=
"Node"
;
info_node
+=
"(id = "
+
to_string
(
this
->
id
)
+
"; "
;
info_node
+=
"Node type = "
+
to_string
(
this
->
node_type_
)
+
"; "
;
info_node
+=
"Goal = "
+
this
->
goal_
+
"; "
;
info_node
+=
"Value = "
+
to_string
(
this
->
value_
)
+
"; "
;
info_node
+=
"Parents = "
+
this
->
get_children
()
+
"; "
;
info_node
+=
"Children = "
+
this
->
get_parents
()
+
")"
;
return
info_node
;
}
int
TreeNode
::
current_id
=
0
;
This diff is collapsed.
Click to expand it.
src/tree_node.hpp
+
3
−
11
View file @
85beebca
...
...
@@ -71,17 +71,9 @@ class TreeNode{
/* Others methods*/
//Adding...
void
add_child
(
TreeNode
*
new_child
,
TreeNode
*
parent
);
void
add_parent
(
TreeNode
*
new_parent
,
TreeNode
*
child
);
void
add_child_pos
(
TreeNode
*
new_child
,
TreeNode
*
parent
,
int
pos
);
void
add_parent_pos
(
TreeNode
*
new_parent
,
TreeNode
*
child
,
int
pos
);
//Removing...
void
remove_child
(
TreeNode
*
cur_child
,
TreeNode
*
parent
);
void
remove_parent
(
TreeNode
*
cur_parent
,
TreeNode
*
child
);
void
remove_child_pos
(
int
pos
,
TreeNode
*
parent
);
void
remove_parent_pos
(
int
pos
,
TreeNode
*
child
);
string
get_info
();
string
get_parents
();
string
get_children
();
};
...
...
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