1155 static inline CxTreeVisitor cxTreeVisit(CxTree *tree) { |
1155 static inline CxTreeVisitor cxTreeVisit(CxTree *tree) { |
1156 return cxTreeVisitSubtree(tree, tree->root); |
1156 return cxTreeVisitSubtree(tree, tree->root); |
1157 } |
1157 } |
1158 |
1158 |
1159 /** |
1159 /** |
|
1160 * Sets the (new) parent of the specified child. |
|
1161 * |
|
1162 * If the \p child is not already member of the tree, this function behaves |
|
1163 * as #cxTreeAddChildNode(). |
|
1164 * |
|
1165 * @param tree the tree |
|
1166 * @param parent the (new) parent of the child |
|
1167 * @param child the node to add |
|
1168 * @see cxTreeAddChildNode() |
|
1169 */ |
|
1170 __attribute__((__nonnull__)) |
|
1171 void cxTreeSetParent( |
|
1172 CxTree *tree, |
|
1173 void *parent, |
|
1174 void *child |
|
1175 ); |
|
1176 |
|
1177 /** |
1160 * Adds a new node to the tree. |
1178 * Adds a new node to the tree. |
|
1179 * |
|
1180 * If the \p child is already member of the tree, the behavior is undefined. |
|
1181 * Use #cxTreeSetParent() if you want to move a subtree to another location. |
1161 * |
1182 * |
1162 * \attention The node may be externally created, but MUST obey the same rules |
1183 * \attention The node may be externally created, but MUST obey the same rules |
1163 * as if it was created by the tree itself with #cxTreeAddChild() (e.g. use |
1184 * as if it was created by the tree itself with #cxTreeAddChild() (e.g. use |
1164 * the same allocator). |
1185 * the same allocator). |
1165 * |
1186 * |
1166 * @param tree the tree |
1187 * @param tree the tree |
1167 * @param parent the parent of the node to add |
1188 * @param parent the parent of the node to add |
1168 * @param child the node to add |
1189 * @param child the node to add |
1169 */ |
1190 * @see cxTreeSetParent() |
1170 __attribute__((__nonnull__)) |
1191 */ |
1171 static inline void cxTreeAddChildNode( |
1192 __attribute__((__nonnull__)) |
|
1193 void cxTreeAddChildNode( |
1172 CxTree *tree, |
1194 CxTree *tree, |
1173 void *parent, |
1195 void *parent, |
1174 void *child) { |
1196 void *child |
1175 cx_tree_link(parent, child, cx_tree_node_layout(tree)); |
1197 ); |
1176 tree->size++; |
|
1177 } |
|
1178 |
1198 |
1179 /** |
1199 /** |
1180 * Creates a new node and adds it to the tree. |
1200 * Creates a new node and adds it to the tree. |
1181 * |
1201 * |
1182 * With this function you can decide where exactly the new node shall be added. |
1202 * With this function you can decide where exactly the new node shall be added. |