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.

src_nodes may not contain duplicates, but dest_nodes may (the state values will be duplicated accordingly). Any src_states entries for nodes in src_nodes which don't appear in dest_nodes will be ignored. If there are nodes in dest_nodes that don't appear in src_nodes, then EVERY_STATE will be placed in the corresponding position of dest_states.

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:

Versions 1.18 and later have this function.
Some older versions had a function called ReOrderStates_bn which did the same as this one.

See also:

SetNodeProbs_bn    Requires a list of states in the correct order
GetNodeFuncState_bn    Also requires correctly ordered states
GetNodeParents_bn    For the above, the list of states must in parent order
GetNodeFinding_bn    Determine the current state finding of a node
NewCaseset_cs    For sets of node-value pairs
ReorderNodeStates_bn    For the states within a single node

Example:

// MapStateList_bn is equivalent to the below function, but it is much faster
// and it doesn't use the user-data pointers.

void MapStateList (const state_bn*  src_states, const nodelist_bn*  src_nodes,
                         state_bn* dest_states, const nodelist_bn* dest_nodes){
    int i, num_src = LengthNodeList_bn (src_nodes);
    int num_dest = LengthNodeList_bn (dest_nodes);
	 state_bn every = EVERY_STATE;
    for (i = 0;  i < num_dest;  i++)
        SetNodeUserData_bn (NthNode_bn (dest_nodes, i), 0, (void*) every);
    for (i = 0;  i < num_src;   i++)
        SetNodeUserData_bn (NthNode_bn (src_nodes, i), 0, (void*) src_states[i]);
    for (i = 0;  i < num_dest;  i++)
        dest_states[i] = * (state_bn*) GetNodeUserData_bn (NthNode_bn (dest_nodes, i), 0);
}