src/cx/tree.h

changeset 909
f4e00bb3f3b2
parent 908
f49f8a7060aa
equal deleted inserted replaced
908:f49f8a7060aa 909:f4e00bb3f3b2
1194 void *parent, 1194 void *parent,
1195 const void *data 1195 const void *data
1196 ); 1196 );
1197 1197
1198 /** 1198 /**
1199 * A function that is invoked when a node needs to be re-linked to a new parent.
1200 *
1201 * When a node is re-linked, sometimes the contents need to be updated.
1202 * This callback is invoked by #cxTreeRemove() so that those updates can be
1203 * applied when re-linking the children of the removed node.
1204 *
1205 * @param node the affected node
1206 * @param old_parent the old parent of the node
1207 * @param new_parent the new parent of the node
1208 */
1209 typedef void (*cx_tree_relink_func)(
1210 void *node,
1211 const void *old_parent,
1212 const void *new_parent
1213 );
1214
1215 /**
1216 * Removes a node and re-links its children to its former parent.
1217 *
1218 * If the node is not part of the tree, the behavior is undefined.
1219 *
1220 * \note The destructor function, if any, will \em not be invoked. That means
1221 * you will need to free the removed node by yourself, eventually.
1222 *
1223 * @param tree the tree
1224 * @param node the node to remove (must not be the root node)
1225 * @param relink_func optional callback to update the content of each re-linked
1226 * node
1227 * @return zero on success, non-zero if \p node is the root node of the tree
1228 */
1229 __attribute__((__nonnull__(1,2)))
1230 int cxTreeRemove(
1231 CxTree *tree,
1232 void *node,
1233 cx_tree_relink_func relink_func
1234 );
1235
1236 /**
1199 * Removes a node and it's subtree from the tree. 1237 * Removes a node and it's subtree from the tree.
1200 * 1238 *
1201 * If the node is not part of the tree, the behavior is undefined. 1239 * If the node is not part of the tree, the behavior is undefined.
1202 * 1240 *
1203 * \note The destructor function, if any, will \em not be invoked. That means 1241 * \note The destructor function, if any, will \em not be invoked. That means

mercurial