[#BloombergLP-bslalg-RbTreeUtil-insert]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslalg.adoc[bslalg]::xref:BloombergLP/bslalg/RbTreeUtil.adoc[RbTreeUtil]::insert
:relfileprefix: ../../../
:mrdocs:

Insert `newNode` into `tree` according to `comparator`&period;

== Synopsis

Declared in `&lt;bslalg&lowbar;rbtreeutil&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class NODE&lowbar;COMPARATOR&gt;
static
void
insert(
    xref:BloombergLP/bslalg/RbTreeAnchor.adoc[RbTreeAnchor]* tree,
    NODE&lowbar;COMPARATOR const& comparator,
    xref:BloombergLP/bslalg/RbTreeNode.adoc[RbTreeNode]* newNode);
----

== Description

Insert the specified `newNode` into the specified `tree`, organized according to the specified `comparator`&period; The resulting tree will be well&hyphen;formed (see `isWellFormed`)&period; `NODE&lowbar;COMPARATOR` shall be a functor providing a method that can be called as if it had the following signatures&colon; &grave; bool operator()(const RbTreeNode&amp;, const RbTreeNode&amp;) const&semi; &grave; The behavior is undefined unless `comparator` provides a strict weak ordering on objects of type `VALUE`, and `tree` is well&hyphen;formed (see `isWellFormed`)&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *tree*
| well&hyphen;formed tree that receives `newNode`
| *comparator*
| functor used to order nodes in `tree`
| *newNode*
| node to insert into `tree`
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
