mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-12 10:45:13 +01:00
New function to deep-copy a GNode and its children. (#93464, James M.
Sun Feb 22 00:47:04 2004 Matthias Clasen <maclas@gmx.de> * glib/gnode.c (g_node_copy_deep): New function to deep-copy a GNode and its children. (#93464, James M. Cape)
This commit is contained in:
parent
e21dadd6f3
commit
c0b5617ae9
@ -1,3 +1,8 @@
|
|||||||
|
Sun Feb 22 00:47:04 2004 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/gnode.c (g_node_copy_deep): New function to deep-copy a
|
||||||
|
GNode and its children. (#93464, James M. Cape)
|
||||||
|
|
||||||
Sat Feb 21 15:42:39 2004 Soeren Sandmann <sandmann@daimi.au.dk>
|
Sat Feb 21 15:42:39 2004 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||||
|
|
||||||
* glib/gqueue.c: Some documentation fixes.
|
* glib/gqueue.c: Some documentation fixes.
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
Sun Feb 22 00:47:04 2004 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/gnode.c (g_node_copy_deep): New function to deep-copy a
|
||||||
|
GNode and its children. (#93464, James M. Cape)
|
||||||
|
|
||||||
Sat Feb 21 15:42:39 2004 Soeren Sandmann <sandmann@daimi.au.dk>
|
Sat Feb 21 15:42:39 2004 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||||
|
|
||||||
* glib/gqueue.c: Some documentation fixes.
|
* glib/gqueue.c: Some documentation fixes.
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
Sun Feb 22 00:47:04 2004 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/gnode.c (g_node_copy_deep): New function to deep-copy a
|
||||||
|
GNode and its children. (#93464, James M. Cape)
|
||||||
|
|
||||||
Sat Feb 21 15:42:39 2004 Soeren Sandmann <sandmann@daimi.au.dk>
|
Sat Feb 21 15:42:39 2004 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||||
|
|
||||||
* glib/gqueue.c: Some documentation fixes.
|
* glib/gqueue.c: Some documentation fixes.
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
Sun Feb 22 00:47:04 2004 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/gnode.c (g_node_copy_deep): New function to deep-copy a
|
||||||
|
GNode and its children. (#93464, James M. Cape)
|
||||||
|
|
||||||
Sat Feb 21 15:42:39 2004 Soeren Sandmann <sandmann@daimi.au.dk>
|
Sat Feb 21 15:42:39 2004 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||||
|
|
||||||
* glib/gqueue.c: Some documentation fixes.
|
* glib/gqueue.c: Some documentation fixes.
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
Sun Feb 22 00:47:04 2004 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/gnode.c (g_node_copy_deep): New function to deep-copy a
|
||||||
|
GNode and its children. (#93464, James M. Cape)
|
||||||
|
|
||||||
Sat Feb 21 15:42:39 2004 Soeren Sandmann <sandmann@daimi.au.dk>
|
Sat Feb 21 15:42:39 2004 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||||
|
|
||||||
* glib/gqueue.c: Some documentation fixes.
|
* glib/gqueue.c: Some documentation fixes.
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
Sun Feb 22 00:47:04 2004 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/gnode.c (g_node_copy_deep): New function to deep-copy a
|
||||||
|
GNode and its children. (#93464, James M. Cape)
|
||||||
|
|
||||||
Sat Feb 21 15:42:39 2004 Soeren Sandmann <sandmann@daimi.au.dk>
|
Sat Feb 21 15:42:39 2004 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||||
|
|
||||||
* glib/gqueue.c: Some documentation fixes.
|
* glib/gqueue.c: Some documentation fixes.
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
Sun Feb 22 00:59:11 2004 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/tmpl/trees-nary.sgml: Document GCopyFunc.
|
||||||
|
|
||||||
|
Sun Feb 22 00:54:17 2004 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* glib/glib-sections.txt: Add GCopyFunc and g_node_copy_deep.
|
||||||
|
|
||||||
2004-02-18 Sebastian Wilhelmi <seppi@seppi.de>
|
2004-02-18 Sebastian Wilhelmi <seppi@seppi.de>
|
||||||
|
|
||||||
* glib/glib-sections.txt: Add the new g_rand_* functions
|
* glib/glib-sections.txt: Add the new g_rand_* functions
|
||||||
|
@ -1699,6 +1699,8 @@ g_tree_destroy
|
|||||||
GNode
|
GNode
|
||||||
g_node_new
|
g_node_new
|
||||||
g_node_copy
|
g_node_copy
|
||||||
|
GCopyFunc
|
||||||
|
g_node_copy_deep
|
||||||
|
|
||||||
<SUBSECTION>
|
<SUBSECTION>
|
||||||
g_node_insert
|
g_node_insert
|
||||||
|
@ -83,13 +83,35 @@ Used to create the first node in a tree.
|
|||||||
<!-- ##### FUNCTION g_node_copy ##### -->
|
<!-- ##### FUNCTION g_node_copy ##### -->
|
||||||
<para>
|
<para>
|
||||||
Recursively copies a #GNode (but does not deep-copy the data inside the nodes,
|
Recursively copies a #GNode (but does not deep-copy the data inside the nodes,
|
||||||
since there's no way for GLib to know how to do that).
|
see g_node_copy_deep() if you need that).
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@node: a #GNode.
|
@node: a #GNode.
|
||||||
@Returns: a new #GNode containing the same data pointers.
|
@Returns: a new #GNode containing the same data pointers.
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### USER_FUNCTION GCopyFunc ##### -->
|
||||||
|
<para>
|
||||||
|
A function of this signature is used to copy the node data when doing a deep-copy
|
||||||
|
of a tree.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@src: A pointer to the data which should be copied.
|
||||||
|
@data: Additional data.
|
||||||
|
@Returns: A pointer to the copy.
|
||||||
|
@Since: 2.4
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION g_node_copy_deep ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@node:
|
||||||
|
@copy_func:
|
||||||
|
@data:
|
||||||
|
@Returns:
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### FUNCTION g_node_insert ##### -->
|
<!-- ##### FUNCTION g_node_insert ##### -->
|
||||||
<para>
|
<para>
|
||||||
Inserts a #GNode beneath the parent at the given position.
|
Inserts a #GNode beneath the parent at the given position.
|
||||||
|
39
glib/gnode.c
39
glib/gnode.c
@ -229,6 +229,45 @@ g_node_unlink (GNode *node)
|
|||||||
node->prev = NULL;
|
node->prev = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_node_copy_deep:
|
||||||
|
* @node: a #GNode
|
||||||
|
* @copy_func: the function which is called to copy the data inside each node,
|
||||||
|
* or %NULL to use the original data.
|
||||||
|
* @data: data to pass to @copy_func
|
||||||
|
*
|
||||||
|
* Recursively copies a #GNode and its data.
|
||||||
|
*
|
||||||
|
* Return value: a new #GNode containing copies of the data in @node.
|
||||||
|
*
|
||||||
|
* Since: 2.4
|
||||||
|
**/
|
||||||
|
GNode*
|
||||||
|
g_node_copy_deep (GNode *node,
|
||||||
|
GCopyFunc copy_func,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GNode *new_node = NULL;
|
||||||
|
|
||||||
|
if (copy_func == NULL)
|
||||||
|
return g_node_copy (node);
|
||||||
|
|
||||||
|
if (node)
|
||||||
|
{
|
||||||
|
GNode *child, *new_child;
|
||||||
|
|
||||||
|
new_node = g_node_new (copy_func (node->data, data));
|
||||||
|
|
||||||
|
for (child = g_node_last_child (node); child; child = child->prev)
|
||||||
|
{
|
||||||
|
new_child = g_node_copy_deep (child, copy_func, data);
|
||||||
|
g_node_prepend (new_node, new_child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new_node;
|
||||||
|
}
|
||||||
|
|
||||||
GNode*
|
GNode*
|
||||||
g_node_copy (GNode *node)
|
g_node_copy (GNode *node)
|
||||||
{
|
{
|
||||||
|
@ -55,6 +55,8 @@ typedef gboolean (*GNodeTraverseFunc) (GNode *node,
|
|||||||
gpointer data);
|
gpointer data);
|
||||||
typedef void (*GNodeForeachFunc) (GNode *node,
|
typedef void (*GNodeForeachFunc) (GNode *node,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
typedef gpointer (*GCopyFunc) (gconstpointer src,
|
||||||
|
gpointer data);
|
||||||
|
|
||||||
/* N-way tree implementation
|
/* N-way tree implementation
|
||||||
*/
|
*/
|
||||||
@ -77,6 +79,9 @@ void g_node_pop_allocator (void);
|
|||||||
GNode* g_node_new (gpointer data);
|
GNode* g_node_new (gpointer data);
|
||||||
void g_node_destroy (GNode *root);
|
void g_node_destroy (GNode *root);
|
||||||
void g_node_unlink (GNode *node);
|
void g_node_unlink (GNode *node);
|
||||||
|
GNode* g_node_copy_deep (GNode *node,
|
||||||
|
GCopyFunc copy_func,
|
||||||
|
gpointer data);
|
||||||
GNode* g_node_copy (GNode *node);
|
GNode* g_node_copy (GNode *node);
|
||||||
GNode* g_node_insert (GNode *parent,
|
GNode* g_node_insert (GNode *parent,
|
||||||
gint position,
|
gint position,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user