NORSYS SOFTWARE © 2012 | NETICA API | C   VERSION   5.04  |
node_bn* RemoveNthNode_bn ( | nodelist_bn* nodes, int index ) |
Removes (and returns) the node at position index from the list nodes, making the list one shorter, and maintaining the order of the rest of the nodes.
index can range from zero (the first node) to LengthNodeList_bn(nodes) - 1 (the last node), or it can be LAST_ENTRY which also indicates the last node.
If index is outside these bounds, the list will not be changed and an error will be generated.
Removing nodes from the end of the list executes the fastest.
Version:
See also:
AddNodeToList_bn | (reverse operation) Adds a node to the list, lengthening it | |
NthNode_bn | Get a node from the list without removing it | |
LengthNodeList_bn | Find maximum node index | |
DupNodeList_bn | To duplicate a list before modifying it |
Example:
Example 2:The following function is available in NeticaEx.c:// Removes node from the list nodes. // node must be in the list, and appear only once, or an error is generated. // void RemoveOneNodeFromList (node_bn* node, nodelist_bn* nodes){ int i = IndexOfNodeInList (node, nodes); RemoveNthNode_bn (nodes, i); }
Example 3:The following function is available in NeticaEx.c:// Removes the first occurrence of node from the list. // If node doesn't appear in the list, it does nothing. // void RemoveNodeFromListIfThere (node_bn* node, nodelist_bn* nodes){ int i = IndexOfNodeInList_bn (node, nodes, 0); if (i != -1) RemoveNthNode_bn (nodes, i); }
The following function is available in NeticaEx.c:// This achieves the same purpose as RemoveNthNode_bn. // Since removing the last node is fastest, this will execute // more quickly (for long lists), but the order won't be maintained. // void RemoveNthNodeFast (int index, nodelist_bn* nodes){ node_bn* lastnode = RemoveNthNode_bn (nodes, LAST_ENTRY); SetNthNode_bn (nodes, index, lastnode); }