[#BloombergLP-bdlc-IndexClerk]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlc.adoc[bdlc]::IndexClerk
:relfileprefix: ../../
:mrdocs:

This class defines an efficient, value&hyphen;semantic manager type for reusable, non&hyphen;negative integer indices&period; The class invariants are that the all decommissioned indices must be non&hyphen;negative, less than the next new index, and unique&period;

== Synopsis

Declared in `&lt;bdlc&lowbar;indexclerk&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class IndexClerk;
----

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlc/IndexClerk/2constructor-0a.adoc[`IndexClerk`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/bdlc/IndexClerk/2destructor.adoc[`&#126;IndexClerk`] [.small]#[destructor]#
| Destroy this index clerk&period;
| xref:BloombergLP/bdlc/IndexClerk/operator_assign.adoc[`operator&equals;`] 
| Assign to this index clerk the value of the specified `rhs` index clerk, and return a reference to this modifiable index clerk&period;
| xref:BloombergLP/bdlc/IndexClerk/bdexStreamIn.adoc[`bdexStreamIn`] 
| Assign to this object the value read from the specified input `stream` using the specified `version` format, and return a reference to `stream`&period; If `stream` is initially invalid, this operation has no effect&period; If `version` is not supported, this object is unaltered and `stream` is invalidated, but otherwise unmodified&period; If `version` is supported but `stream` becomes invalid during this operation, this object has an undefined, but valid, state&period; Note that no version is read from `stream`&period; See the `bslx` package&hyphen;level documentation for more information on BDEX streaming of value&hyphen;semantic types and containers&period;
| xref:BloombergLP/bdlc/IndexClerk/bdexStreamOut.adoc[`bdexStreamOut`] 
| Write the value of this object, using the specified `version` format, to the specified output `stream`, and return a reference to `stream`&period; If `stream` is initially invalid, this operation has no effect&period; If `version` is not supported, `stream` is invalidated, but otherwise unmodified&period; Note that `version` is not written to `stream`&period; See the `bslx` package&hyphen;level documentation for more information on BDEX streaming of value&hyphen;semantic types and containers&period;
| xref:BloombergLP/bdlc/IndexClerk/begin.adoc[`begin`] 
| Return a `IndexClerkIter` referring to the first index returned to this `IndexClerk` that is currently unused, or `end()` if there are currently no decommissioned indices&period;
| xref:BloombergLP/bdlc/IndexClerk/end.adoc[`end`] 
| Return a `IndexClerkIter` referring to an invalid index, indicating the end of the sequence of decommissioned index&period;
| xref:BloombergLP/bdlc/IndexClerk/getIndex.adoc[`getIndex`] 
| Return the next available unused integer index&period; Existing decommissioned indices are reissued before new ones are created&period;
| xref:BloombergLP/bdlc/IndexClerk/isInUse.adoc[`isInUse`] 
| Return `true` if the specified `index` is currently in use, and `false` otherwise&period; The behavior is undefined unless `0 &lt;&equals; index` and `index &lt; nextNewIndex()`&period; Note that this method runs in time proportional to the number of decommissioned indices&period;
| xref:BloombergLP/bdlc/IndexClerk/nextNewIndex.adoc[`nextNewIndex`] 
| Return the smallest (non&hyphen;negative) index that has not been issued by this index clerk&period; Note that this function offers the client a &quot;peek&quot; at the next &quot;new&quot; index, but has no effect on the value of this index clerk&period;
| xref:BloombergLP/bdlc/IndexClerk/numCommissionedIndices.adoc[`numCommissionedIndices`] 
| Return the number of indices currently in use&period;
| xref:BloombergLP/bdlc/IndexClerk/numDecommissionedIndices.adoc[`numDecommissionedIndices`] 
| Return the number of indices that are currently decommissioned&period;
| xref:BloombergLP/bdlc/IndexClerk/print.adoc[`print`] 
| Format this index clerk to the specified output `stream` at the (absolute value of) the optionally specified indentation `level` and return a reference to `stream`&period; If `level` is specified, optionally specify `spacesPerLevel`, the number of spaces per indentation level for this and all of its nested objects&period; If `level` is negative, suppress indentation of the first line&period; If `spacesPerLevel` is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by `level`)&period; If `stream` is not valid on entry, this operation has no effect&period;
| xref:BloombergLP/bdlc/IndexClerk/putIndex.adoc[`putIndex`] 
| Return the specified `index` to this index clerk, which indicates that `index` is no longer in use and may be reissued&period; The behavior is undefined if `index` has never been generated by this clerk or is currently decommissioned&period;
| xref:BloombergLP/bdlc/IndexClerk/removeAll.adoc[`removeAll`] 
| Remove all of the indices from this index clerk&period; Note that the following post conditions apply&colon; &grave; assert(0 &equals;&equals; numCommissionedIndices())&semi; assert(0 &equals;&equals; numDecommissionedIndices())&semi; assert(0 &equals;&equals; nextNewIndex())&semi; &grave;
| xref:BloombergLP/bdlc/IndexClerk/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;IndexClerk, UsesBslmaAllocator&gt;`] 
| Declare that this type uses a `bslma` allocator&period;
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlc/IndexClerk/maxSupportedBdexVersion-09.adoc[`maxSupportedBdexVersion`] 
| `maxSupportedBdexVersion` overloads
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:BloombergLP/bdlc/operator_not_eq-014.adoc[BloombergLP::bdlc::operator!&equals;]`
| Return `true` if the specified `lhs` and `rhs` index clerks do not have the same value, and `false` otherwise&period; Two `IndexClerk` objects do not have the same value if they do not have the same `nextNewIndex()`, or might generate different sequences of integer indices&period;
| `xref:BloombergLP/bdlc/operator_eq-0e2.adoc[BloombergLP::bdlc::operator&equals;&equals;]`
| Return `true` if the specified `lhs` and `rhs` index clerks have the same value, and `false` otherwise&period; Two `IndexClerk` objects have the same value if they have the same `nextNewIndex()` and would always generate the same sequence of integer indices&period;
|===


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