BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bdlc_indexclerk.h
Go to the documentation of this file.
1/// @file bdlc_indexclerk.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bdlc_indexclerk.h -*-C++-*-
8#ifndef INCLUDED_BDLC_INDEXCLERK
9#define INCLUDED_BDLC_INDEXCLERK
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bdlc_indexclerk bdlc_indexclerk
15/// @brief Provide a manager of reusable, non-negative integer indices.
16/// @addtogroup bdl
17/// @{
18/// @addtogroup bdlc
19/// @{
20/// @addtogroup bdlc_indexclerk
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bdlc_indexclerk-purpose"> Purpose</a>
25/// * <a href="#bdlc_indexclerk-classes"> Classes </a>
26/// * <a href="#bdlc_indexclerk-description"> Description </a>
27/// * <a href="#bdlc_indexclerk-performance"> Performance </a>
28/// * <a href="#bdlc_indexclerk-usage"> Usage </a>
29/// * <a href="#bdlc_indexclerk-example-1-basic-usage"> Example 1: Basic Usage </a>
30///
31/// # Purpose {#bdlc_indexclerk-purpose}
32/// Provide a manager of reusable, non-negative integer indices.
33///
34/// # Classes {#bdlc_indexclerk-classes}
35///
36/// - bdlc::IndexClerkIter: sequential accessor to decommissioned indices
37/// - bdlc::IndexClerk: manager of reusable, non-negative integer indices
38///
39/// # Description {#bdlc_indexclerk-description}
40/// This component implements an efficient, value-semantic manager
41/// class for reusable, non-negative integer indices. Each new instance of a
42/// `bdlc::IndexClerk` will issue consecutive integers on request, beginning
43/// with `0, 1, 2, ...`. Indices that are no longer needed may be returned for
44/// reuse. Existing decommissioned indices are reissued before any new ones are
45/// created. Value-semantic operations such as copy construction and
46/// assignment, equality comparison, and streaming are also provided. Finally,
47/// a `bdlc::IndexClerkIter` is provided to enable sequential, read-only access
48/// to the currently decommissioned indices. Note that the order of iteration
49/// is not defined.
50///
51/// ## Performance {#bdlc_indexclerk-performance}
52///
53///
54/// The following characterizes the performance of representative operations
55/// using "big-oh" notation, O[f(N,M)], where the names `N` and `M` also refer
56/// to the number of respective elements in the sequence of decommissioned
57/// indices.
58/// @code
59/// Operation Worst Case
60/// --------- ----------
61/// DEFAULT CTOR O[1]
62/// COPY CTOR(N) O[N]
63/// N.DTOR() O[1]
64/// N.OP=(M) O[M]
65/// OP==(N,M) O[min(N,M)]
66///
67/// N.getIndex() O[1]
68/// N.putIndex(index) O[1]
69/// N.removeAll() O[1]
70/// N.numCommissionedIndices() O[1]
71/// N.numDecommissionedIndices() O[1]
72/// N.nextNewIndex() O[1]
73/// N.isInUse(index) O[N]
74/// @endcode
75///
76/// ## Usage {#bdlc_indexclerk-usage}
77///
78///
79/// This section illustrates intended use of this component.
80///
81/// ### Example 1: Basic Usage {#bdlc_indexclerk-example-1-basic-usage}
82///
83///
84/// A `bdlc::IndexClerk` is commonly used in conjunction with an array to enable
85/// machine-address-independent referencing. Rather than dynamically allocating
86/// an object and holding its address, the object is stored in the array at the
87/// next position dispensed by its associated `bdlc::IndexClerk`, and that index
88/// becomes an identifier (Id) for the new object. Instead of destroying an
89/// unneeded object, its Id is merely returned to the clerk.
90///
91/// Care must be taken to ensure that objects "created" at reused indices (i.e.,
92/// indices below the current length of the array) *replace* (the value of) an
93/// existing object in the array while objects created at new indices (i.e.,
94/// indices at the current length) are *appended* to the array.
95///
96/// For example, suppose we have a security class object. To add and remove
97/// security values from a security array/clerk pair, you might write the
98/// following two functions:
99/// @code
100/// /// Add a copy of the specified `newSecurity` to the specified
101/// /// `securityArray` at the index dispensed by the specified
102/// /// `securityClerk`. Also update the `securityClerk`, and return the id
103/// /// (in `securityArray`) for the newly added security.
104/// int addSecurity(bsl::vector<Security> *securityArray,
105/// bdlc::IndexClerk *securityClerk,
106/// const Security& newSecurity)
107/// {
108/// BSLS_ASSERT(securityArray);
109/// BSLS_ASSERT(securityClerk);
110///
111/// int id = securityClerk->getIndex();
112///
113/// if (id < securityArray->size()) {
114/// (*securityArray)[id] = newSecurity;
115/// }
116/// else {
117/// securityArray->push_back(newSecurity);
118/// }
119///
120/// return id;
121/// }
122///
123/// /// Remove the security object identified by the specified `securityId`
124/// /// from the specified `securityArray`, and update the specified
125/// /// `securityClerk` (making `securityId` available for reuse). The
126/// /// behavior is undefined unless `securityId` refers to an active
127/// /// security in `securityArray` dispensed by `securityClerk`.
128/// void removeSecurity(bsl::vector<Security> *securityArray,
129/// bdlc::IndexClerk *securityClerk,
130/// int securityId)
131/// {
132/// BSLS_ASSERT(securityArray);
133/// BSLS_ASSERT(securityClerk);
134///
135/// BSLS_ASSERT(0 <= securityId);
136/// BSLS_ASSERT(securityClerk->nextNewIndex() > securityId);
137/// BSLS_ASSERT(securityArray->size() > securityId);
138///
139/// // Note that the 'isInUse' function (below) runs in linear time.
140///
141/// BSLS_ASSERT_SAFE(securityClerk->isInUse(securityId));
142///
143/// (*securityArray)[securityId] = Security(); // optional
144/// securityClerk->putIndex(securityId);
145/// }
146/// @endcode
147/// @}
148/** @} */
149/** @} */
150
151/** @addtogroup bdl
152 * @{
153 */
154/** @addtogroup bdlc
155 * @{
156 */
157/** @addtogroup bdlc_indexclerk
158 * @{
159 */
160
161#include <bdlscm_version.h>
162
165
166#include <bslma_allocator.h>
168
171
172#include <bsls_assert.h>
173#include <bsls_platform.h>
174#include <bsls_review.h>
175
176#include <bsl_iosfwd.h>
177#include <bsl_iterator.h>
178#include <bsl_vector.h>
179
180
181namespace bdlc {
182
183 // ====================
184 // class IndexClerkIter
185 // ====================
186
187/// This class defines an in-core value-semantic iterator providing
188/// sequential read-only access to the decommissioned indices of a
189/// `IndexClerk`. The order of iteration is implementation dependent.
190///
191/// See @ref bdlc_indexclerk
193
194 // DATA
195 bsl::reverse_iterator<const int *> d_index_p; // pointer to current
196 // decommissioned index
197
198 // FRIENDS
199 friend bool operator==(const IndexClerkIter& lhs,
200 const IndexClerkIter& rhs);
201 friend bool operator!=(const IndexClerkIter& lhs,
202 const IndexClerkIter& rhs);
203 public:
204 // TRAITS
206
207 // CREATORS
208
209 /// Create an unbound iterator.
211
212 /// Create an iterator referring to the specified integer `index`.
213 IndexClerkIter(const int *index);
214
215 /// Create an iterator having the same value as the specified `original`
216 /// iterator.
217 IndexClerkIter(const IndexClerkIter& original);
218
219 //~IndexClerkIter();
220 // Destroy this index clerk iterator. Note that this method is
221 // generated by the compiler.
222
223 // MANIPULATORS
224
225 /// Create an iterator having the same value as the specified `rhs`
226 /// iterator.
228
229 /// Increment this iterator to refer to the next index in the
230 /// corresponding sequence of decommissioned indices. Return a
231 /// reference to this modifiable iterator.
232 ///
233 /// \pre The behavior is undefined unless the current index is within the range `[ begin() .. end() )`.
235
236 /// Decrement this iterator to refer to the previous index in the
237 /// corresponding sequence of decommissioned indices. Return a
238 /// reference to this modifiable iterator.
239 ///
240 /// \pre The behavior is undefined unless the current index is within the range `( begin() .. end() ]`.
242
243 // ACCESSORS
244
245 /// Return the value of the integer to which this iterator currently refers.
246 ///
247 /// \pre The behavior is undefined unless the iterator is within the
248 /// range `[ begin() .. end() )`.
249 int operator*() const;
250};
251
252/// Return `true` if `lhs` and `rhs` have the same value and `false`
253/// otherwise. Two iterators have the same value if they refer to the same
254/// element of the same container or if they both have the end iterator value for the same container.
255///
256/// \pre The behavior is undefined unless `lhs`
257/// and `rhs` refer to the same container and are non-singular (i.e., are
258/// not default-constructed or copies of singular iterators).
259bool operator==(const IndexClerkIter& lhs, const IndexClerkIter& rhs);
260
261/// Return `true` if `lhs` and `rhs` do not have the same value and `false`
262/// otherwise. Two iterators do not have the same value if they do not
263/// refer to the same element of the same container or if one has the end
264/// iterator value of a container and the other refers to an element (not the end) of the same container.
265///
266/// \pre The behavior is undefined unless `lhs`
267/// and `rhs` refer to the same container and are non-singular (i.e., are
268/// not default-constructed or copies of singular iterators).
269bool operator!=(const IndexClerkIter& lhs, const IndexClerkIter& rhs);
270
271 // ================
272 // class IndexClerk
273 // ================
274
275/// This class defines an efficient, value-semantic manager type for
276/// reusable, non-negative integer indices. The class invariants are that
277/// the all decommissioned indices must be non-negative, less than the next
278/// new index, and unique.
279///
280/// See @ref bdlc_indexclerk
282
283 // DATA
284 bsl::vector<int> d_unusedStack; // stack of decommissioned indices
285 int d_nextNewIndex; // next unused index to be created
286
287 // FRIENDS
288 friend bool operator==(const IndexClerk&, const IndexClerk&);
289 friend bool operator!=(const IndexClerk&, const IndexClerk&);
290
291 // PRIVATE CLASS METHODS
292
293 /// Return `true` if the class invariants of the object represented by
294 /// the specified `unusedStack` are preserved and `false` otherwise.
295 /// The class invariants are that all decommissioned indices are
296 /// non-negative, less than the specified `nextNewIndex`, and unique.
297 ///
298 /// \note Note that the run time of this function is proportional to
299 /// `numDecommissionedIndices()`, but it requires temporary space that
300 /// is proportional to `nextNewIndex`.
301 static bool areInvariantsPreserved(const bsl::vector<int>& unusedStack,
302 int nextNewIndex);
303
304 public:
305 // TRAITS
307
308 // CLASS METHODS
309
310 /// Return the maximum valid BDEX format version, as indicated by the
311 /// specified `versionSelector`, to be passed to the `bdexStreamOut` method.
312 ///
313 /// \note Note that it is highly recommended that `versionSelector`
314 /// be formatted as "YYYYMMDD", a date representation. Also note that
315 /// `versionSelector` should be a *compile*-time-chosen value that
316 /// selects a format version supported by both externalizer and
317 /// unexternalizer. See the `bslx` package-level documentation for more
318 /// information on BDEX streaming of value-semantic types and
319 /// containers.
320 static int maxSupportedBdexVersion(int versionSelector);
321
322 // CREATORS
323
324 /// Create a new index clerk that dispenses consecutive non-negative
325 /// integers beginning with `0, 1, 2, ...`; however, indices returned
326 /// via `putIndex` will be reissued before any new ones are created.
327 /// Optionally specify a `basicAllocator` used to supply memory. If
328 /// `basicAllocator` is 0, the currently installed default allocator is
329 /// used.
330 explicit IndexClerk(bslma::Allocator *basicAllocator = 0);
331
332 /// Create a new index clerk having the value of the specified
333 /// `original` index clerk. Optionally specify a `basicAllocator` used
334 /// to supply memory. If `basicAllocator` is 0, the currently installed
335 /// default allocator is used.
336 IndexClerk(const IndexClerk& original,
337 bslma::Allocator *basicAllocator = 0);
338
339 /// Destroy this index clerk.
340 ~IndexClerk();
341
342 // MANIPULATORS
343
344 /// Assign to this index clerk the value of the specified `rhs` index
345 /// clerk, and return a reference to this modifiable index clerk.
346 IndexClerk& operator=(const IndexClerk& rhs);
347
348
349 /// Assign to this object the value read from the specified input
350 /// `stream` using the specified `version` format, and return a
351 /// reference to `stream`. If `stream` is initially invalid, this
352 /// operation has no effect. If `version` is not supported, this object
353 /// is unaltered and `stream` is invalidated, but otherwise unmodified.
354 /// If `version` is supported but `stream` becomes invalid during this
355 /// operation, this object has an undefined, but valid, state.
356 ///
357 /// \note Note that no version is read from `stream`. See the `bslx` package-level
358 /// documentation for more information on BDEX streaming of
359 /// value-semantic types and containers.
360 template <class STREAM>
361 STREAM& bdexStreamIn(STREAM& stream, int version);
362
363 /// Return the next available unused integer index. Existing
364 /// decommissioned indices are reissued before new ones are created.
365 int getIndex();
366
367 /// Return the specified `index` to this index clerk, which indicates
368 /// that `index` is no longer in use and may be reissued.
369 ///
370 /// \pre The behavior is undefined if `index` has never been generated by this clerk or is
371 /// currently decommissioned.
372 void putIndex(int index);
373
374 /// Remove all of the indices from this index clerk.
375 /// \note Note that the
376 /// following post conditions apply:
377 /// @code
378 /// assert(0 == numCommissionedIndices());
379 /// assert(0 == numDecommissionedIndices());
380 /// assert(0 == nextNewIndex());
381 /// @endcode
382 void removeAll();
383
384 // ACCESSORS
385
386 /// Write the value of this object, using the specified `version`
387 /// format, to the specified output `stream`, and return a reference to
388 /// `stream`. If `stream` is initially invalid, this operation has no
389 /// effect. If `version` is not supported, `stream` is invalidated, but otherwise unmodified.
390 ///
391 /// \note Note that `version` is not written to
392 /// `stream`. See the `bslx` package-level documentation for more
393 /// information on BDEX streaming of value-semantic types and
394 /// containers.
395 template <class STREAM>
396 STREAM& bdexStreamOut(STREAM& stream, int version) const;
397
398 /// Return a `IndexClerkIter` referring to the first index returned to
399 /// this `IndexClerk` that is currently unused, or `end()` if there are
400 /// currently no decommissioned indices.
401 IndexClerkIter begin() const;
402
403 /// Return a `IndexClerkIter` referring to an invalid index, indicating
404 /// the end of the sequence of decommissioned index.
405 IndexClerkIter end() const;
406
407 /// Return `true` if the specified `index` is currently in use, and `false` otherwise.
408 ///
409 /// \pre The behavior is undefined unless `0 <= index` and `index < nextNewIndex()`.
410 ///
411 /// \note Note that this method runs in time
412 /// proportional to the number of decommissioned indices.
413 bool isInUse(int index) const;
414
415 /// Return the number of indices currently in use.
416 int numCommissionedIndices() const;
417
418 /// Return the number of indices that are currently decommissioned.
419 int numDecommissionedIndices() const;
420
421 /// Return the smallest (non-negative) index that has not been issued by this index clerk.
422 ///
423 /// \note Note that this function offers the client a
424 /// "peek" at the next "new" index, but has no effect on the value of
425 /// this index clerk.
426 int nextNewIndex() const;
427
428 /// Format this index clerk to the specified output `stream` at the
429 /// (absolute value of) the optionally specified indentation `level` and
430 /// return a reference to `stream`. If `level` is specified, optionally
431 /// specify `spacesPerLevel`, the number of spaces per indentation level
432 /// for this and all of its nested objects. If `level` is negative,
433 /// suppress indentation of the first line. If `spacesPerLevel` is
434 /// negative, format the entire output on one line, suppressing all but
435 /// the initial indentation (as governed by `level`). If `stream` is
436 /// not valid on entry, this operation has no effect.
437 bsl::ostream& print(bsl::ostream& stream,
438 int level = 0,
439 int spacesPerLevel = 4) const;
440
441#ifndef BDE_OMIT_INTERNAL_DEPRECATED // pending deprecation
442
443 /// Return the most current BDEX streaming version number supported by
444 /// this class.
445 ///
446 /// @deprecated Use @ref maxSupportedBdexVersion(int) instead.
447 static int maxSupportedBdexVersion();
448
449#endif // BDE_OMIT_INTERNAL_DEPRECATED -- pending deprecation
450};
451
452// FREE OPERATORS
453
454/// Return `true` if the specified `lhs` and `rhs` index clerks have the same
455/// value, and `false` otherwise. Two `IndexClerk` objects have the same value
456/// if they have the same `nextNewIndex()` and would always generate the same
457/// sequence of integer indices.
458bool operator==(const IndexClerk& lhs, const IndexClerk& rhs);
459
460/// Return `true` if the specified `lhs` and `rhs` index clerks do not have the
461/// same value, and `false` otherwise. Two `IndexClerk` objects do not have
462/// the same value if they do not have the same `nextNewIndex()`, or might
463/// generate different sequences of integer indices.
464bool operator!=(const IndexClerk& lhs, const IndexClerk& rhs);
465
466/// Write the specified `rhs` index clerk to the specified output `stream` in
467/// some single-line (human-readable) format, and return a reference to the
468/// modifiable `stream`.
469bsl::ostream& operator<<(bsl::ostream& stream, const IndexClerk& rhs);
470
471// ============================================================================
472// INLINE DEFINITIONS
473// ============================================================================
474
475 // --------------------
476 // class IndexClerkIter
477 // --------------------
478
479// CREATORS
480inline
482: d_index_p(0)
483{
484}
485
486inline
488: d_index_p(index)
489{
490}
491
492inline
494: d_index_p(original.d_index_p)
495{
496}
497
498// MANIPULATORS
499inline
502{
503 d_index_p = rhs.d_index_p;
504 return *this;
505}
506
507inline
509{
510 BSLS_ASSERT(0 != d_index_p.base());
511
512 ++d_index_p;
513 return *this;
514}
515
516inline
518{
519 BSLS_ASSERT(0 != d_index_p.base());
520
521 --d_index_p;
522 return *this;
523}
524
525// ACCESSORS
526inline
528{
529#if defined(BSLS_PLATFORM_CMP_GNU) && \
530 BSLS_PLATFORM_CMP_VERSION >= 120000 && BSLS_PLATFORM_CMP_VERSION < 150000
531 // See implementation notes in the .cpp file for explanation.
532#pragma GCC diagnostic push
533#pragma GCC diagnostic ignored "-Warray-bounds"
534#endif
535 BSLS_ASSERT(0 != d_index_p.base());
536
537 return *d_index_p;
538#if defined(BSLS_PLATFORM_CMP_GNU) && \
539 BSLS_PLATFORM_CMP_VERSION >= 120000 && BSLS_PLATFORM_CMP_VERSION < 150000
540#pragma GCC diagnostic pop
541#endif
542}
543
544} // close package namespace
545
546// FREE OPERATORS
547inline
548bool bdlc::operator==(const IndexClerkIter& lhs, const IndexClerkIter& rhs)
549{
550 return lhs.d_index_p == rhs.d_index_p;
551}
552
553inline
554bool bdlc::operator!=(const IndexClerkIter& lhs, const IndexClerkIter& rhs)
555{
556 return lhs.d_index_p != rhs.d_index_p;
557}
558
559namespace bdlc {
560
561 // ----------------
562 // class IndexClerk
563 // ----------------
564
565// CREATORS
566inline
568: d_unusedStack(basicAllocator)
569, d_nextNewIndex(0)
570{
571}
572
573inline
575 bslma::Allocator *basicAllocator)
576: d_unusedStack(original.d_unusedStack, basicAllocator)
577, d_nextNewIndex(original.d_nextNewIndex)
578{
579}
580
581inline
583{
584 BSLS_ASSERT_SAFE(areInvariantsPreserved(d_unusedStack, d_nextNewIndex));
585}
586
587// MANIPULATORS
588inline
590{
591 d_unusedStack = rhs.d_unusedStack;
592 d_nextNewIndex = rhs.d_nextNewIndex;
593 return *this;
594}
595
596inline
598{
599 if (d_unusedStack.empty()) {
600 return d_nextNewIndex++; // RETURN
601 }
602 else {
603 int index = d_unusedStack.back();
604 d_unusedStack.pop_back();
605 return index; // RETURN
606 }
607}
608
609inline
610void IndexClerk::putIndex(int index)
611{
612 BSLS_ASSERT(0 <= index);
613 BSLS_ASSERT( index < d_nextNewIndex);
615
616 d_unusedStack.push_back(index);
617}
618
619inline
621{
622 d_unusedStack.clear();
623 d_nextNewIndex = 0;
624}
625
626// Note: Order changed from declaration to make use of inlined 'removeAll'.
627
628template <class STREAM>
629STREAM& IndexClerk::bdexStreamIn(STREAM& stream, int version)
630{
631 switch (version) {
632 case 1: {
633 int nextNewIndex;
634 stream.getInt32(nextNewIndex);
635
636 if (!stream || nextNewIndex < 0) {
637 stream.invalidate();
638 return stream; // RETURN
639 }
640
641 bsl::vector<int> unusedStack;
642 bslx::InStreamFunctions::bdexStreamIn(stream, unusedStack, version);
643
644 // Stream can be invalidated after streaming in 'd_unusedStack'.
645
646 if (!stream || !areInvariantsPreserved(unusedStack, nextNewIndex)) {
647 stream.invalidate();
648 return stream; // RETURN
649 }
650
651 d_unusedStack = unusedStack;
652 d_nextNewIndex = nextNewIndex;
653 } break;
654 default: {
655 stream.invalidate();
656 } break;
657 }
658 return stream;
659}
660
661// ACCESSORS
662template <class STREAM>
663inline
664STREAM& IndexClerk::bdexStreamOut(STREAM& stream, int version) const
665{
666 if (stream) {
667 switch (version) { // switch on the schema version
668 case 1: {
669 stream.putInt32(d_nextNewIndex);
671 stream, d_unusedStack, version);
672 } break;
673 default: {
674 stream.invalidate(); // unrecognized version number
675 }
676 }
677 }
678 return stream;
679}
680
681inline
683{
684 return d_nextNewIndex - static_cast<int>(d_unusedStack.size());
685}
686
687inline
689{
690 return IndexClerkIter(d_unusedStack.begin() + d_unusedStack.size());
691}
692
693inline
695{
696 return IndexClerkIter(d_unusedStack.begin());
697}
698
699inline
701{
702 return static_cast<int>(d_unusedStack.size());
703}
704
705inline
707{
708 return d_nextNewIndex;
709}
710
711inline
712int IndexClerk::maxSupportedBdexVersion(int /* versionSelector */)
713{
714 return 1;
715}
716
717#ifndef BDE_OMIT_INTERNAL_DEPRECATED // pending deprecation
718
719// DEPRECATED METHODS
720inline
725
726#endif // BDE_OMIT_INTERNAL_DEPRECATED -- pending deprecation
727
728} // close package namespace
729
730// FREE OPERATORS
731inline
732bool bdlc::operator==(const IndexClerk& lhs, const IndexClerk& rhs)
733{
734 return lhs.d_nextNewIndex == rhs.d_nextNewIndex
735 && lhs.d_unusedStack == rhs.d_unusedStack;
736}
737
738inline
739bool bdlc::operator!=(const IndexClerk& lhs, const IndexClerk& rhs)
740{
741 return lhs.d_nextNewIndex != rhs.d_nextNewIndex
742 || lhs.d_unusedStack != rhs.d_unusedStack;
743}
744
745inline
746bsl::ostream& bdlc::operator<<(bsl::ostream& stream, const IndexClerk& rhs)
747{
748 return rhs.print(stream, 0, -1);
749}
750
751
752
753#endif
754
755// ----------------------------------------------------------------------------
756// Copyright 2018 Bloomberg Finance L.P.
757//
758// Licensed under the Apache License, Version 2.0 (the "License");
759// you may not use this file except in compliance with the License.
760// You may obtain a copy of the License at
761//
762// http://www.apache.org/licenses/LICENSE-2.0
763//
764// Unless required by applicable law or agreed to in writing, software
765// distributed under the License is distributed on an "AS IS" BASIS,
766// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
767// See the License for the specific language governing permissions and
768// limitations under the License.
769// ----------------------------- END-OF-FILE ----------------------------------
770
771/** @} */
772/** @} */
773/** @} */
Definition bdlc_indexclerk.h:192
friend bool operator==(const IndexClerkIter &lhs, const IndexClerkIter &rhs)
IndexClerkIter & operator++()
Definition bdlc_indexclerk.h:508
IndexClerkIter & operator=(const IndexClerkIter &rhs)
Definition bdlc_indexclerk.h:501
IndexClerkIter()
Create an unbound iterator.
Definition bdlc_indexclerk.h:481
IndexClerkIter & operator--()
Definition bdlc_indexclerk.h:517
BSLMF_NESTED_TRAIT_DECLARATION(IndexClerkIter, bslmf::IsBitwiseCopyable)
friend bool operator!=(const IndexClerkIter &lhs, const IndexClerkIter &rhs)
int operator*() const
Definition bdlc_indexclerk.h:527
Definition bdlc_indexclerk.h:281
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
STREAM & bdexStreamIn(STREAM &stream, int version)
Definition bdlc_indexclerk.h:629
IndexClerk(bslma::Allocator *basicAllocator=0)
Definition bdlc_indexclerk.h:567
friend bool operator!=(const IndexClerk &, const IndexClerk &)
static int maxSupportedBdexVersion()
Definition bdlc_indexclerk.h:721
IndexClerk & operator=(const IndexClerk &rhs)
Definition bdlc_indexclerk.h:589
int getIndex()
Definition bdlc_indexclerk.h:597
void putIndex(int index)
Definition bdlc_indexclerk.h:610
BSLMF_NESTED_TRAIT_DECLARATION(IndexClerk, bslma::UsesBslmaAllocator)
IndexClerkIter end() const
Definition bdlc_indexclerk.h:694
int numDecommissionedIndices() const
Return the number of indices that are currently decommissioned.
Definition bdlc_indexclerk.h:700
int numCommissionedIndices() const
Return the number of indices currently in use.
Definition bdlc_indexclerk.h:682
void removeAll()
Definition bdlc_indexclerk.h:620
IndexClerkIter begin() const
Definition bdlc_indexclerk.h:688
bool isInUse(int index) const
STREAM & bdexStreamOut(STREAM &stream, int version) const
Definition bdlc_indexclerk.h:664
int nextNewIndex() const
Definition bdlc_indexclerk.h:706
~IndexClerk()
Destroy this index clerk.
Definition bdlc_indexclerk.h:582
friend bool operator==(const IndexClerk &, const IndexClerk &)
size_type size() const BSLS_KEYWORD_NOEXCEPT
Return the number of elements in this vector.
Definition bslstl_vector.h:3019
iterator begin() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_vector.h:2866
reference back()
Definition bslstl_vector.h:2932
bool empty() const BSLS_KEYWORD_NOEXCEPT
Return true if this vector has size 0, and false otherwise.
Definition bslstl_vector.h:3034
Definition bslstl_vector.h:1120
void push_back(const VALUE_TYPE &value)
Definition bslstl_vector.h:4343
void swap(vector &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits void clear() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_vector.h:1938
void pop_back()
Definition bslstl_vector.h:4375
Definition bslma_allocator.h:545
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1976
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1917
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition bdlc_bitarray.h:506
bool operator==(const BitArray &lhs, const BitArray &rhs)
bool operator!=(const BitArray &lhs, const BitArray &rhs)
BitArray operator<<(const BitArray &array, bsl::size_t numBits)
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
ALLOCATOR & lhs
Definition bslstl_string.h:3917
STREAM & bdexStreamIn(STREAM &stream, VALUE_TYPE &variable)
Definition bslx_instreamfunctions.h:1263
STREAM & bdexStreamOut(STREAM &stream, const TYPE &value)
Definition bslx_outstreamfunctions.h:1004
Definition bslma_usesbslmaallocator.h:344
Definition bslmf_isbitwisecopyable.h:298