BloombergLP::bdlc::IndexClerk

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

Synopsis

Declared in <bdlc_indexclerk.h>

class IndexClerk;

Member Functions

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

Static Member Functions

NameDescription
maxSupportedBdexVersion maxSupportedBdexVersion overloads

Friends

NameDescription
BloombergLP::bdlc::operator!=Return true if the specified lhs and rhs index clerks do not have the same value, and false otherwise. 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.
BloombergLP::bdlc::operator==Return true if the specified lhs and rhs index clerks have the same value, and false otherwise. Two IndexClerk objects have the same value if they have the same nextNewIndex() and would always generate the same sequence of integer indices.