Cartesius Library
|
Implements trees and procedures to use them. More...
Data Types | |
interface | DoSomethingTo2Nodes |
Does nothing. More... | |
interface | DoSomethingTo2NodesWithArg |
Does nothing. More... | |
interface | DoSomethingToNode |
Interface to apply a one-node operation to the whole tree using DoSomethingToTree. More... | |
interface | DoSomethingToNodeWithArg |
Interface to apply a one-node operation to the whole tree using DoSomethingToTreeWithArg. More... | |
type | node |
type | node_ptr |
Functions/Subroutines | |
subroutine | copynode (someNode, copy) |
Copies every field of the node to a copy. More... | |
subroutine | initialize_new_tree (someValue, root, pDeallocator) |
Creates new tree. The result is a node with name 'root', of rank zero, which points to the passed value. More... | |
recursive subroutine | find_node_by_name (someName, tree, pNode) |
Returns a pointer to the node with the specified name. The desired node must be one of the chidren or siblings of the input node. More... | |
type(node) function, pointer | find_node_by_name_fn (tree, someName) |
Same as above, but can be used as a function. More... | |
recursive subroutine | find_node_by_value (pValue, tree, pNode) |
Returns the node with the first (depth-first) occurence of the given value in the tree. More... | |
type(node) function, pointer | find_node_by_value_fn (tree, pValue) |
Same as above, but can be used as a function. More... | |
class(*) function, pointer | get_value (pNode) |
Returns the value stored in the given node. If pNode points to null, returns a null-pointer. More... | |
class(*) function, pointer | get_value_by_name (someName, tree) |
Returns a pointer to the value in the node with the specified name. More... | |
class(*) function, pointer | get_value_by_name2 (tree, someName) |
Same as above, but changed arguments to use as type-bound procedure. More... | |
recursive subroutine | dosomethingtotree (tree, pSomething) |
Applies the procedure in the pSomething pointer to every child and sibling recursively. More... | |
recursive subroutine | dosomethingtotreewitharg (tree, pSomething, arg) |
Applies the procedure (which takes an argument) in the pSomething pointer to every child and sibling recursively. More... | |
recursive subroutine | dosomethingto2trees (tree1, tree2, pSomething) |
recursive subroutine | dosomethingto2treeswitharg (tree1, tree2, pSomething, arg) |
subroutine | dosomethingtosomenodes (tree, Names, pSomething) |
Applies the procedure in the pSomething pointer to every node with the name from the Names array. More... | |
subroutine | dosomethingtosomenodeswitharg (tree, Names, pSomething, arg) |
subroutine | printtree (tree) |
Passes a pointer to the printNode subroutine to DoSomethingToTree. More... | |
subroutine | printnode (someNode) |
If the value in the node is of type real, prints the value. More... | |
subroutine | printnode_new (someNode) |
A prettier output for the contents of a node. More... | |
recursive subroutine | printtree_new (tree, line, pProcedure) |
Draws the structure of the tree. More... | |
subroutine | find_common_predecessor (someName1, someName2, tree, pPred) |
Finds the first common predecessor of two nodes in the tree. More... | |
subroutine | find_common_predecessor_for_three (someName1, someName2, someName3, tree, pPred) |
Finds the common predecessor for three nodes by calling find_common_predecessor twice. More... | |
recursive subroutine | update_tree_rank (this) |
Updates the ranks of a subtree's nodes based on the parent of the provided node. Useful when moving or grafting. More... | |
type(node) function, pointer | getroot (this) |
Returns the root of the tree, given the node. More... | |
subroutine | add_child_to_node (parent_node, new_name, new_value, pDeallocator, result_node) |
subroutine | add_node (parentName, newName, tree, newValue, pDeallocator, result_node) |
Adds node to the tree as a new child of a specified node. More... | |
subroutine | add_node2 (tree, parentName, newName, newValue, pDeallocator, result_node) |
Same as above, but changed the order to use as a type-bound procedure. More... | |
subroutine | graft (this, new_branch) |
Grafts the new_branch node as one of the children of this and refactors the ranks of all its children. More... | |
type(node) function, pointer | node_from_polymorphic (x) |
Converts a polymorphic pointer to a node pointer if possible, else returns a null-pointer. More... | |
recursive subroutine | deallocate_tree_native (this, start) |
Destroys all data contained in the (sub)tree. Presence of start allows to remove the siblings of the starting node. Otherwise, they will be untouched. For use with pDeallocator, use deallocate_tree_poly. More... | |
subroutine | deallocate_tree (pTree) |
Same subroutine as deallocate_tree to pass as pDeallocator. More... | |
subroutine | remove_node (someName, tree, pNodeOut) |
Remove a node from the tree by rearranging the pointers. More... | |
subroutine | purge_node (someName, tree) |
subroutine | move_node_from_one_parent_to_another (nodeName, newParentName, tree) |
Moving node with its child from one parent to another. More... | |
Variables | |
integer, parameter, public | max_char =120 |
character(len=4), parameter, public | key_root = 'root' |
Implements trees and procedures to use them.
subroutine polymorphic_tree::add_child_to_node | ( | class(node), intent(in), target | parent_node, |
character(len=*), intent(in) | new_name, | ||
class(*), intent(in), pointer | new_value, | ||
procedure(deallocatorprocedure), intent(in), optional, pointer | pDeallocator, | ||
type(node), intent(out), optional, pointer | result_node | ||
) |
subroutine polymorphic_tree::add_node | ( | character(len=*), intent(in) | parentName, |
character(len=*), intent(in) | newName, | ||
type(node), intent(inout) | tree, | ||
class(*), intent(in), pointer | newValue, | ||
procedure(deallocatorprocedure), intent(in), optional, pointer | pDeallocator, | ||
type(node), intent(out), optional, pointer | result_node | ||
) |
Adds node to the tree as a new child of a specified node.
tree | of type node must contain the node with name parentName. |
subroutine polymorphic_tree::add_node2 | ( | class(node), intent(inout) | tree, |
character(len=*), intent(in) | parentName, | ||
character(len=*), intent(in) | newName, | ||
class(*), intent(in), pointer | newValue, | ||
procedure(deallocatorprocedure), intent(in), optional, pointer | pDeallocator, | ||
type(node), intent(out), optional, pointer | result_node | ||
) |
Same as above, but changed the order to use as a type-bound procedure.
add_node
above and rename add_node2
. subroutine polymorphic_tree::copynode | ( | type(node), intent(in) | someNode, |
type(node), intent(out) | copy | ||
) |
Copies every field of the node to a copy.
subroutine polymorphic_tree::deallocate_tree | ( | class(*), intent(inout), pointer | pTree | ) |
Same subroutine as deallocate_tree to pass as pDeallocator.
recursive subroutine polymorphic_tree::deallocate_tree_native | ( | type(node), intent(inout), pointer | this, |
logical, intent(in), optional | start | ||
) |
Destroys all data contained in the (sub)tree. Presence of start
allows to remove the siblings of the starting node. Otherwise, they will be untouched. For use with pDeallocator, use deallocate_tree_poly.
recursive subroutine polymorphic_tree::dosomethingto2trees | ( | type(node), intent(inout) | tree1, |
type(node), intent(inout) | tree2, | ||
procedure(dosomethingto2nodes), intent(in), pointer | pSomething | ||
) |
recursive subroutine polymorphic_tree::dosomethingto2treeswitharg | ( | type(node), intent(inout) | tree1, |
type(node), intent(inout) | tree2, | ||
procedure(dosomethingto2nodeswitharg), intent(in), pointer | pSomething, | ||
class(*), intent(inout), pointer | arg | ||
) |
subroutine polymorphic_tree::dosomethingtosomenodes | ( | type(node), intent(inout) | tree, |
character(len=*), dimension(:), intent(in) | Names, | ||
procedure(dosomethingtonode), intent(in), pointer | pSomething | ||
) |
Applies the procedure in the pSomething pointer to every node with the name from the Names array.
subroutine polymorphic_tree::dosomethingtosomenodeswitharg | ( | type(node), intent(inout) | tree, |
character(len=*), dimension(:), intent(in) | Names, | ||
procedure(dosomethingtonodewitharg), intent(in), pointer | pSomething, | ||
class(*), intent(inout), pointer | arg | ||
) |
recursive subroutine polymorphic_tree::dosomethingtotree | ( | type(node), intent(inout) | tree, |
procedure(dosomethingtonode), intent(in), pointer | pSomething | ||
) |
Applies the procedure in the pSomething pointer to every child and sibling recursively.
recursive subroutine polymorphic_tree::dosomethingtotreewitharg | ( | type(node), intent(inout) | tree, |
procedure(dosomethingtonodewitharg), intent(in), pointer | pSomething, | ||
class(*), intent(inout), pointer | arg | ||
) |
Applies the procedure (which takes an argument) in the pSomething pointer to every child and sibling recursively.
subroutine polymorphic_tree::find_common_predecessor | ( | character(len=*), intent(in) | someName1, |
character(len=*), intent(in) | someName2, | ||
type(node), intent(in) | tree, | ||
type(node), intent(out), pointer | pPred | ||
) |
Finds the first common predecessor of two nodes in the tree.
subroutine polymorphic_tree::find_common_predecessor_for_three | ( | character(len=*), intent(in) | someName1, |
character(len=*), intent(in) | someName2, | ||
character(len=*), intent(in) | someName3, | ||
type(node), intent(in) | tree, | ||
type(node), intent(out), pointer | pPred | ||
) |
Finds the common predecessor for three nodes by calling find_common_predecessor twice.
recursive subroutine polymorphic_tree::find_node_by_name | ( | character(len=*), intent(in) | someName, |
type(node), intent(in), target | tree, | ||
type(node), intent(inout), pointer | pNode | ||
) |
Returns a pointer to the node with the specified name. The desired node must be one of the chidren or siblings of the input node.
type(node) function, pointer polymorphic_tree::find_node_by_name_fn | ( | class(node), intent(in) | tree, |
character(len=*), intent(in) | someName | ||
) |
Same as above, but can be used as a function.
recursive subroutine polymorphic_tree::find_node_by_value | ( | class(*), intent(in), pointer | pValue, |
type(node), intent(in), target | tree, | ||
type(node), intent(inout), pointer | pNode | ||
) |
Returns the node with the first (depth-first) occurence of the given value in the tree.
type(node) function, pointer polymorphic_tree::find_node_by_value_fn | ( | class(node), intent(in) | tree, |
class(*), intent(in), pointer | pValue | ||
) |
Same as above, but can be used as a function.
class(*) function, pointer polymorphic_tree::get_value | ( | type(node), pointer | pNode | ) |
Returns the value stored in the given node. If pNode points to null, returns a null-pointer.
class(*) function, pointer polymorphic_tree::get_value_by_name | ( | character (len=*) | someName, |
class(node) | tree | ||
) |
Returns a pointer to the value in the node with the specified name.
class(*) function, pointer polymorphic_tree::get_value_by_name2 | ( | class(node) | tree, |
character (len=*) | someName | ||
) |
Same as above, but changed arguments to use as type-bound procedure.
Returns the root of the tree, given the node.
subroutine polymorphic_tree::graft | ( | class(node), intent(inout), target | this, |
type(node), intent(inout), target | new_branch | ||
) |
Grafts the new_branch
node as one of the children of this
and refactors the ranks of all its children.
subroutine polymorphic_tree::initialize_new_tree | ( | class(*), intent(in), pointer | someValue, |
type(node), intent(out) | root, | ||
procedure(deallocatorprocedure), intent(in), optional, pointer | pDeallocator | ||
) |
Creates new tree. The result is a node with name 'root', of rank zero, which points to the passed value.
subroutine polymorphic_tree::move_node_from_one_parent_to_another | ( | character(len=*), intent(in) | nodeName, |
character(len=*), intent(in) | newParentName, | ||
type(node), intent(inout) | tree | ||
) |
Moving node with its child from one parent to another.
type(node) function, pointer polymorphic_tree::node_from_polymorphic | ( | class(*), intent(in), pointer | x | ) |
Converts a polymorphic pointer to a node pointer if possible, else returns a null-pointer.
subroutine polymorphic_tree::printnode | ( | type(node), intent(inout) | someNode | ) |
If the value in the node is of type real, prints the value.
subroutine polymorphic_tree::printnode_new | ( | class(node), intent(inout) | someNode | ) |
A prettier output for the contents of a node.
subroutine polymorphic_tree::printtree | ( | class(node) | tree | ) |
Passes a pointer to the printNode subroutine to DoSomethingToTree.
recursive subroutine polymorphic_tree::printtree_new | ( | class(node), intent(inout) | tree, |
character(len=*), intent(in), optional, target | line, | ||
procedure(dosomethingtonodewitharg), intent(in), optional, pointer | pProcedure | ||
) |
Draws the structure of the tree.
tree | The printed tree will contain this node and all of its substructure. |
line | (optional) Can be used to provide padding before every output line. Is meant to exist only as a workaround to help with pretty output. |
pProcedure | (optional) If there is need to output data structures that polymorphic_tree_mod doesn't know about, you can supply your own output procedure. Note that all of the output will be forwarded to pProcedure, so make sure that it handles that well (see organicum/organicum_mod.f90:print_atomic_node_new for an example) |
subroutine polymorphic_tree::purge_node | ( | character(len=*), intent(in) | someName, |
type(node), intent(inout) | tree | ||
) |
subroutine polymorphic_tree::remove_node | ( | character(len=*), intent(in) | someName, |
type(node), intent(inout) | tree, | ||
type(node), intent(out), optional, pointer | pNodeOut | ||
) |
Remove a node from the tree by rearranging the pointers.
recursive subroutine polymorphic_tree::update_tree_rank | ( | class(node), intent(inout) | this | ) |
Updates the ranks of a subtree's nodes based on the parent of the provided node. Useful when moving or grafting.
character(len=4), parameter, public polymorphic_tree::key_root = 'root' |
integer, parameter, public polymorphic_tree::max_char =120 |