[#BloombergLP-bslstl-HashTable-reserveForNumElements]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslstl.adoc[bslstl]::xref:BloombergLP/bslstl/HashTable.adoc[HashTable]::reserveForNumElements
:relfileprefix: ../../../
:mrdocs:

Reserve capacity for at least `numElements` without exceeding max load&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;hashtable&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
void
reserveForNumElements(xref:BloombergLP/bslstl/HashTable/SizeType.adoc[SizeType] numElements);
----

== Description

Re&hyphen;organize this hash&hyphen;table to have a sufficient number of buckets to accommodate at least the specified `numElements` without exceeding the `maxLoadFactor`, and ensure that there are sufficient nodes pre&hyphen;allocated in this object&apos;s node pool&period; If this function tries to allocate a number of buckets larger than can be represented by this hash table&apos;s `SizeType`, a `std&colon;&colon;length&lowbar;error` exception is thrown&period; This operation provides the strong exception guarantee (see &lcub;`bsldoc&lowbar;glossary`&rcub;) unless the `hasher` throws, in which case this operation provides the basic exception guarantee, leaving the hash&hyphen;table in a valid, but otherwise unspecified (and potentially empty), state&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *numElements*
| minimum number of elements to accommodate
|===


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