![]() |
NORSYS SOFTWARE © 2002 | NETICA API | C   VERSION   2.15  |
void MapStateList_bn ( | const state_bn* src_states, const nodelist_bn* src_nodes, state_bn* dest_states, const nodelist_bn* dest_nodes ) |
Puts into the dest_states array the same states that are in the src_states array, except in a different order.
The order of src_states is given by src_nodes, and the order of dest_states will be given by dest_nodes.
Neither dest_nodes nor src_nodes may contain duplicates.
dest_nodes must contain exactly the same nodes as src_nodes, but possibly in a different order.
The idea is that each entry of src_states contains a value of the corresponding node in src_nodes, and now we want these values in the order given by dest_nodes.
Version:
Example:
// MapStateList_bn is equivalent to the below function, but it doesn't use // the user data pointer, which the below does. #include <assert.h> void MapStateList_bn (const state_bn* src_states,const nodelist_bn* src_nodes, state_bn* dest_states, const nodelist_bn* dest_nodes){ int nn, num_nodes = LengthNodeList_bn (src_nodes); for (nn = 0; nn < num_nodes; nn++) SetNodeUserData_bn (NthNode_bn (src_nodes, nn), 0, (void*) &src_states[nn]); for (nn = 0; nn < num_nodes; nn++){ void* data = GetNodeUserData_bn (NthNode_bn (dest_nodes, nn), 0); assert (data != NULL); dest_states[nn] = * (state_bn*) data; } }