| NORSYS SOFTWARE © 2010 | NETICA API | C VERSION 4.18

int IndexOfNodeInList_bn ( | const node_bn* node, const nodelist_bn* nodes, int start_index )

Returns the position (index) of node in the list nodes, or -1 if it was not found.

It starts searching at index start_index; pass 0 to search the whole list.

It is okay if node is NULL.

Version:

Versions 2.11 and later have this function.

See also:

NthNode_bn |  | (inverse function) Returns the index, given the node
GetNodeNamed_bn |  | Search for node by name
LengthNodeList_bn |  | Returns the maximum node index

Example:

    The following function is available in NeticaEx.c:
    // Like IndexOfNodeInList_bn, but generates an error if there is not exactly
    //   one instance of node in list nodes.
    //
    int IndexOfNodeInList (const node_bn* node, const nodelist_bn* nodes){
        int i = IndexOfNodeInList_bn (node, nodes, 0);
        if (i == -1)
            NewError (env, 901, ERROR_ERR,
                      "IndexOfNodeInList: There is no node '%s' in the list",
                      node ? GetNodeName_bn (node) : "null");
        else {
            int second = IndexOfNodeInList_bn (node, nodes, i + 1);
            if (second != -1)
                NewError (env, 902, ERROR_ERR,
                          "IndexOfNodeInList: There is more than one instance of node '%s' in the
                           list",
                          node ? GetNodeName_bn (node) : "null");
        }
        return i;
    }

Example 2:

    See GetNodeNamed_bn example 'FindNodeNamed' to search a node list for a node with a given name.