Copy original into empty result using nodeFactory.

Synopsis

Declared in <bslalg_rbtreeutil.h>

template<class FACTORY>
static
void
copyTree(
    RbTreeAnchor* result,
    RbTreeAnchor const& original,
    FACTORY* nodeFactory);

Description

Load, into the specified result, a collection of newly created nodes having the same red‐black tree structure as that of the specified original tree, where each node in the returned tree is created by invoking nodeFactory‐>createNode on the corresponding original node; if an exception occurs, use nodeFactory‐>deleteNode to destroy any newly created nodes, and propagate the exception to the caller (i.e., this operation provides the strong exception guarantee). FACTORY shall be a class providing two methods that can be called as if they had the following signatures: ` RbTreeNode *createNode(const RbTreeNode&); void deleteNode(RbTreeNode *); ` The behavior is undefined unless result is an empty tree, original is a well‐formed (see isWellFormed), and nodeFactory‐>deleteNode does not throw.

Parameters

Name

Description

result

empty tree that receives the copied nodes

original

well‐formed tree to copy

nodeFactory

factory used to create and destroy nodes

Created with MrDocs