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

Return the address of the node holding the specified `value` in the specified `tree` (organized according to the specified `comparator`) if found, and the address of the node that would be the parent for `value` otherwise&semi; load, into the specified `comparisonResult`, 0 if `value` is found, a negative number if `value` would be held in its left child, and a positive number if `value` would be held in its right child, unless `tree` is empty, in which case load a negative number into `comparisonResult` and return `tree&hyphen;&gt;sentinel()`&period; Optionally specify a `hint`, suggesting a node in `tree` that might be the immediate successor of a node holding `value` if it were to be inserted into `tree`&period; If the supplied `hint` is the successor, this operation will take amortized constant time&semi; otherwise, it will take O(log(N)) operations, where N is the number of nodes in the tree&period; If a node holding `value` is inserted as suggested by this method, the resulting tree will be an ordered binary tree, but may require rebalancing (and re&hyphen;coloring) to again be a valid red&hyphen;black tree&period; `COMPARATOR` shall be a functor providing two methods that can be called as if they have the following signatures&colon; &grave; bool operator()(const RbTreeNode&amp;, const VALUE&amp;) const&semi; bool operator()(const VALUE&amp;, const RbTreeNode&amp;) const&semi; &grave; The behavior is undefined unless `comparator` provides a strict weak ordering on objects of type `VALUE`, `tree` is well&hyphen;formed (see `isWellFormed`), and `hint`, if supplied, is a node in `tree`&period; Note that this operation is intended to be used in conjunction with the `insertAt` method&period;

== Synopsis

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

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


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