class route_node #( type T = int )
Implements a node of a route.
| T | optional The type of data collected in a route_node. The default is int. |
| route_node | Implements a node of a route. |
| Types | |
| route_node_type | The shorthand of the route node type specialized with type T. |
| Properties | |
| id | The globally unique ID of this node. |
| elem | The element stored at this route node. |
| from_nodes | The nodes this node is connected from. |
| to_nodes | The nodes this node is connected to. |
| relatives | The route nodes this route node is related to. |
| Functions | |
| new | Creates a new route node. |
| add | virtual Creates a route node of the given element and adds it as a new to_nodes. |
| connect | virtual Connects the given route node (and its connections) as a new to_nodes. |
| disconnect | virtual Removes the specified route node (and its connections) from this node. |
| get_num_of_to_nodes | virtual Returns the number of to_nodes. |
| has_to_nodes | virtual Returns if this route node has at least one to_nodes. |
| get_index | virtual Returns the index of the to_nodes this node is connected to, from the view point of the specified “from node”. |
route_node_type from_nodes[$]
The nodes this node is connected from.
+---------------+ +-----------+ | from_nodes[0] |--->| | +---------------+ | | +---------------+ | | | from_nodes[1] |--->| this node | +---------------+ | | +---------------+ | | | from_nodes[2] |--->| | +---------------+ +-----------+
virtual function route_node_type add( T e )
virtual Creates a route node of the given element and adds it as a new to_nodes.
| e | An element to be added. |
Newly added route node.
route_node#(int) rn; route_node#(int) rn_123 = new( 123 ); rn = rn_123.add( 234 ); // (123) ---- (234) <~~ rn rn = rn_123.add( 345 ); // (123) -+-- (234) // | // +-- (345) <~~ rn rn = rn_123.add( 456 ).add( 567 ); // chain // (123) -+-- (234) // | // +-- (345) // | // +-- (456) ---- (567) <~~ rn
virtual function route_node_type connect( route_node_type rn )
virtual Connects the given route node (and its connections) as a new to_nodes.
| rn | A route node to be connected. |
A route node to be connected (rn).
route_node#(int) rn_123; route_node#(int) rn_234; route_node#(int) rn_345; route_node#(int) rn_456; route_node#(int) rn; rn_123 = new( 123 ); rn_234 = rn_123.add( 234 ); // (123) --- (234) // \__ rn_234 rn_345 = new( 345 ); rn_456 = rn_345.add( 456 ); // (345) ---- (456) // \__ rn_345 rn = rn_234.connect( rn_345 ); // (123) ---- (234) --- (345) ---- (456) // \__ rn
virtual function route_node_type disconnect( int index = 0 )
virtual Removes the specified route node (and its connections) from this node.
| index | optional The index of the to_nodes. The default is 0. If the specified node does not exist, this function does nothing. |
This route node.
route_node#(int) rn; route_node#(int) rn_123 = new( 123 ); rn = rn_123.add( 234 ); rn = rn_123.add( 456 ).add( 567 ); rn = rn_123.add( 345 ); // (123) -+-- (234) // | // +-- (456) ---- (567) // | // +-- (345) rn = rn_123.disconnect( .index( 1 ) ); // (123) -+-- (234) // | // +-- (345)
virtual function int get_num_of_to_nodes()
virtual Returns the number of to_nodes. This function does not count the number of connections recursively.
The number of to_nodes.
route_node#(int) rn; route_node#(int) rn_123 = new( 123 ); rn = rn_123.add( 234 ); rn = rn_123.add( 345 ); rn = rn_123.add( 456 ).add( 567 ); // (123) -+-- (234) // | // +-- (345) // | // +-- (456) ---- (567) assert( rn_123.get_num_of_to_nodes() == 3 ); // not 4
virtual function bit has_to_nodes()
virtual Returns if this route node has at least one to_nodes.
If this tree node has at least one to_nodes, returns 1. Otherwise, returns 0.
route_node#(int) rn; route_node#(int) rn_123 = new( 123 ); rn = rn_123.add( 234 ); rn = rn_123.add( 345 ); rn = rn_123.add( 456 ).add( 567 ); // (123) -+-- (234) // | // +-- (345) // | // +-- (456) ---- (567) assert( rn_123.has_to_nodes() == 1 );
virtual function int get_index( int from_node_index )
virtual Returns the index of the to_nodes this node is connected to, from the view point of the specified “from node”.
The index of the to_nodes of the specified “from node”. If the specified “from node” does not exist, returns -1.
route_node#(int) from_node0 = new( 0 ); route_node#(int) from_node1 = new( 1 ); route_node#(int) to_node0 = new( 2 ); route_node#(int) to_node1 = new( 3 ); route_node#(int) this_node = new( 4 ); route_node#(int) rn; rn = from_node0.connect( this_node ); rn = from_node1.connect( to_node0 ); rn = from_node1.connect( to_node1 ); rn = from_node1.connect( this_node ); // +---------------+ +------+ // | from_nodes[0] |------to_nodes[0]----->| | // +---------------+ | | // +---------------+ +-------------+ | | // | from_nodes[1] |--->| to_nodes[0] | | this | // | | +-------------+ | | // | | +-------------+ | node | // | |--->| to_nodes[1] | | | // | | +-------------+ | | // | |------to_nodes[2]----->| | // +---------------+ +------+ assert( this_node.get_index( .from_node_index( 0 ) ) == 0 ); assert( this_node.get_index( .from_node_index( 1 ) ) == 2 );
Implements a node of a route.
class route_node #( type T = int )
Implements a route structure.
class route #( type T = int ) extends collection#( T )
The shorthand of the route node type specialized with type T.
typedef route_node#( T ) route_node_type
The globally unique ID of this node.
int id
The element stored at this route node.
T elem
The nodes this node is connected from.
route_node_type from_nodes[$]
The nodes this node is connected to.
route_node_type to_nodes[$]
The route nodes this route node is related to.
route_node_type relatives[$]
Creates a new route node.
function new( T elem )
virtual Creates a route node of the given element and adds it as a new to_nodes.
virtual function route_node_type add( T e )
virtual Connects the given route node (and its connections) as a new to_nodes.
virtual function route_node_type connect( route_node_type rn )
virtual Removes the specified route node (and its connections) from this node.
virtual function route_node_type disconnect( int index = 0 )
virtual Returns the number of to_nodes.
virtual function int get_num_of_to_nodes()
virtual Returns if this route node has at least one to_nodes.
virtual function bit has_to_nodes()
virtual Returns the index of the to_nodes this node is connected to, from the view point of the specified “from node”.
virtual function int get_index( int from_node_index )