BDE 4.14.0 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/// int addSecurity(bsl::vector<Security> *securityArray,
101/// bdlc::IndexClerk *securityClerk,
102/// const Security& newSecurity)
103/// // Add a copy of the specified 'newSecurity' to the specified
104/// // 'securityArray' at the index dispensed by the specified
105/// // 'securityClerk'. Also update the 'securityClerk', and return the id
106/// // (in 'securityArray') for the newly added security.
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/// void removeSecurity(bsl::vector<Security> *securityArray,
124/// bdlc::IndexClerk *securityClerk,
125/// int securityId)
126/// // Remove the security object identified by the specified 'securityId'
127/// // from the specified 'securityArray', and update the specified
128/// // 'securityClerk' (making 'securityId' available for reuse). The
129/// // behavior is undefined unless 'securityId' refers to an active
130/// // security in 'securityArray' dispensed by 'securityClerk'.
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. The behavior is undefined
232 /// unless the current index is within the range `[ begin() .. end() )`.
234
235 /// Decrement this iterator to refer to the previous index in the
236 /// corresponding sequence of decommissioned indices. Return a
237 /// reference to this modifiable iterator. The behavior is undefined
238 /// unless the current index is within the range `( begin() .. end() ]`.
240
241 // ACCESSORS
242
243 /// Return the value of the integer to which this iterator currently
244 /// refers. The behavior is undefined unless the iterator is within the
245 /// range `[ begin() .. end() )`.
246 int operator*() const;
247};
248
249/// Return `true` if `lhs` and `rhs` have the same value and `false`
250/// otherwise. Two iterators have the same value if they refer to the same
251/// element of the same container or if they both have the end iterator
252/// value for the same container. The behavior is undefined unless `lhs`
253/// and `rhs` refer to the same container and are non-singular (i.e., are
254/// not default-constructed or copies of singular iterators).
255bool operator==(const IndexClerkIter& lhs, const IndexClerkIter& rhs);
256
257/// Return `true` if `lhs` and `rhs` do not have the same value and `false`
258/// otherwise. Two iterators do not have the same value if they do not
259/// refer to the same element of the same container or if one has the end
260/// iterator value of a container and the other refers to an element (not
261/// the end) of the same container. The behavior is undefined unless `lhs`
262/// and `rhs` refer to the same container and are non-singular (i.e., are
263/// not default-constructed or copies of singular iterators).
264bool operator!=(const IndexClerkIter& lhs, const IndexClerkIter& rhs);
265
266 // ================
267 // class IndexClerk
268 // ================
269
270/// This class defines an efficient, value-semantic manager type for
271/// reusable, non-negative integer indices. The class invariants are that
272/// the all decommissioned indices must be non-negative, less than the next
273/// new index, and unique.
274///
275/// See @ref bdlc_indexclerk
277
278 // DATA
279 bsl::vector<int> d_unusedStack; // stack of decommissioned indices
280 int d_nextNewIndex; // next unused index to be created
281
282 // FRIENDS
283 friend bool operator==(const IndexClerk&, const IndexClerk&);
284 friend bool operator!=(const IndexClerk&, const IndexClerk&);
285
286 // PRIVATE CLASS METHODS
287
288 /// Return `true` if the class invariants of the object represented by
289 /// the specified `unusedStack` are preserved and `false` otherwise.
290 /// The class invariants are that all decommissioned indices are
291 /// non-negative, less than the specified `nextNewIndex`, and unique.
292 /// Note that the run time of this function is proportional to
293 /// `numDecommissionedIndices()`, but it requires temporary space that
294 /// is proportional to `nextNewIndex`.
295 static bool areInvariantsPreserved(const bsl::vector<int>& unusedStack,
296 int nextNewIndex);
297
298 public:
299 // TRAITS
301
302 // CLASS METHODS
303
304 /// Return the maximum valid BDEX format version, as indicated by the
305 /// specified `versionSelector`, to be passed to the `bdexStreamOut`
306 /// method. Note that it is highly recommended that `versionSelector`
307 /// be formatted as "YYYYMMDD", a date representation. Also note that
308 /// `versionSelector` should be a *compile*-time-chosen value that
309 /// selects a format version supported by both externalizer and
310 /// unexternalizer. See the `bslx` package-level documentation for more
311 /// information on BDEX streaming of value-semantic types and
312 /// containers.
313 static int maxSupportedBdexVersion(int versionSelector);
314
315 // CREATORS
316
317 /// Create a new index clerk that dispenses consecutive non-negative
318 /// integers beginning with `0, 1, 2, ...`; however, indices returned
319 /// via `putIndex` will be reissued before any new ones are created.
320 /// Optionally specify a `basicAllocator` used to supply memory. If
321 /// `basicAllocator` is 0, the currently installed default allocator is
322 /// used.
323 explicit IndexClerk(bslma::Allocator *basicAllocator = 0);
324
325 /// Create a new index clerk having the value of the specified
326 /// `original` index clerk. Optionally specify a `basicAllocator` used
327 /// to supply memory. If `basicAllocator` is 0, the currently installed
328 /// default allocator is used.
329 IndexClerk(const IndexClerk& original,
330 bslma::Allocator *basicAllocator = 0);
331
332 /// Destroy this index clerk.
333 ~IndexClerk();
334
335 // MANIPULATORS
336
337 /// Assign to this index clerk the value of the specified `rhs` index
338 /// clerk, and return a reference to this modifiable index clerk.
339 IndexClerk& operator=(const IndexClerk& rhs);
340
341
342 /// Assign to this object the value read from the specified input
343 /// `stream` using the specified `version` format, and return a
344 /// reference to `stream`. If `stream` is initially invalid, this
345 /// operation has no effect. If `version` is not supported, this object
346 /// is unaltered and `stream` is invalidated, but otherwise unmodified.
347 /// If `version` is supported but `stream` becomes invalid during this
348 /// operation, this object has an undefined, but valid, state. Note
349 /// that no version is read from `stream`. See the `bslx` package-level
350 /// documentation for more information on BDEX streaming of
351 /// value-semantic types and containers.
352 template <class STREAM>
353 STREAM& bdexStreamIn(STREAM& stream, int version);
354
355 /// Return the next available unused integer index. Existing
356 /// decommissioned indices are reissued before new ones are created.
357 int getIndex();
358
359 /// Return the specified `index` to this index clerk, which indicates
360 /// that `index` is no longer in use and may be reissued. The behavior
361 /// is undefined if `index` has never been generated by this clerk or is
362 /// currently decommissioned.
363 void putIndex(int index);
364
365 /// Remove all of the indices from this index clerk. Note that the
366 /// following post conditions apply:
367 /// @code
368 /// assert(0 == numCommissionedIndices());
369 /// assert(0 == numDecommissionedIndices());
370 /// assert(0 == nextNewIndex());
371 /// @endcode
372 void removeAll();
373
374 // ACCESSORS
375
376 /// Write the value of this object, using the specified `version`
377 /// format, to the specified output `stream`, and return a reference to
378 /// `stream`. If `stream` is initially invalid, this operation has no
379 /// effect. If `version` is not supported, `stream` is invalidated, but
380 /// otherwise unmodified. Note that `version` is not written to
381 /// `stream`. See the `bslx` package-level documentation for more
382 /// information on BDEX streaming of value-semantic types and
383 /// containers.
384 template <class STREAM>
385 STREAM& bdexStreamOut(STREAM& stream, int version) const;
386
387 /// Return a `IndexClerkIter` referring to the first index returned to
388 /// this `IndexClerk` that is currently unused, or `end()` if there are
389 /// currently no decommissioned indices.
390 IndexClerkIter begin() const;
391
392 /// Return a `IndexClerkIter` referring to an invalid index, indicating
393 /// the end of the sequence of decommissioned index.
394 IndexClerkIter end() const;
395
396 /// Return `true` if the specified `index` is currently in use, and
397 /// `false` otherwise. The behavior is undefined unless `0 <= index`
398 /// and `index < nextNewIndex()`. Note that this method runs in time
399 /// proportional to the number of decommissioned indices.
400 bool isInUse(int index) const;
401
402 /// Return the number of indices currently in use.
403 int numCommissionedIndices() const;
404
405 /// Return the number of indices that are currently decommissioned.
406 int numDecommissionedIndices() const;
407
408 /// Return the smallest (non-negative) index that has not been issued by
409 /// this index clerk. Note that this function offers the client a
410 /// "peek" at the next "new" index, but has no effect on the value of
411 /// this index clerk.
412 int nextNewIndex() const;
413
414 /// Format this index clerk to the specified output `stream` at the
415 /// (absolute value of) the optionally specified indentation `level` and
416 /// return a reference to `stream`. If `level` is specified, optionally
417 /// specify `spacesPerLevel`, the number of spaces per indentation level
418 /// for this and all of its nested objects. If `level` is negative,
419 /// suppress indentation of the first line. If `spacesPerLevel` is
420 /// negative, format the entire output on one line, suppressing all but
421 /// the initial indentation (as governed by `level`). If `stream` is
422 /// not valid on entry, this operation has no effect.
423 bsl::ostream& print(bsl::ostream& stream,
424 int level = 0,
425 int spacesPerLevel = 4) const;
426
427#ifndef BDE_OMIT_INTERNAL_DEPRECATED // pending deprecation
428
429 /// @deprecated Use @ref maxSupportedBdexVersion(int) instead.
430 ///
431 /// Return the most current BDEX streaming version number supported by
432 /// this class.
433 static int maxSupportedBdexVersion();
434
435#endif // BDE_OMIT_INTERNAL_DEPRECATED -- pending deprecation
436};
437
438// FREE OPERATORS
439
440/// Return `true` if the specified `lhs` and `rhs` index clerks have the
441/// same value, and `false` otherwise. Two `IndexClerk` objects have the
442/// same value if they have the same `nextNewIndex()` and would always
443/// generate the same sequence of integer indices.
444bool operator==(const IndexClerk& lhs, const IndexClerk& rhs);
445
446/// Return `true` if the specified `lhs` and `rhs` index clerks do not have
447/// the same value, and `false` otherwise. Two `IndexClerk` objects do not
448/// have the same value if they do not have the same `nextNewIndex()`, or
449/// might generate different sequences of integer indices.
450bool operator!=(const IndexClerk& lhs, const IndexClerk& rhs);
451
452/// Write the specified `rhs` index clerk to the specified output `stream`
453/// in some single-line (human-readable) format, and return a reference to
454/// the modifiable `stream`.
455bsl::ostream& operator<<(bsl::ostream& stream, const IndexClerk& rhs);
456
457// ============================================================================
458// INLINE DEFINITIONS
459// ============================================================================
460
461 // --------------------
462 // class IndexClerkIter
463 // --------------------
464
465// CREATORS
466inline
468: d_index_p(0)
469{
470}
471
472inline
474: d_index_p(index)
475{
476}
477
478inline
480: d_index_p(original.d_index_p)
481{
482}
483
484// MANIPULATORS
485inline
488{
489 d_index_p = rhs.d_index_p;
490 return *this;
491}
492
493inline
495{
496 BSLS_ASSERT(0 != d_index_p.base());
497
498 ++d_index_p;
499 return *this;
500}
501
502inline
504{
505 BSLS_ASSERT(0 != d_index_p.base());
506
507 --d_index_p;
508 return *this;
509}
510
511// ACCESSORS
512inline
514{
515#if defined(BSLS_PLATFORM_CMP_GNU) && \
516 BSLS_PLATFORM_CMP_VERSION >= 120000 && BSLS_PLATFORM_CMP_VERSION < 150000
517 // See implementation notes in the .cpp file for explanation.
518#pragma GCC diagnostic push
519#pragma GCC diagnostic ignored "-Warray-bounds"
520#endif
521 BSLS_ASSERT(0 != d_index_p.base());
522
523 return *d_index_p;
524#if defined(BSLS_PLATFORM_CMP_GNU) && \
525 BSLS_PLATFORM_CMP_VERSION >= 120000 && BSLS_PLATFORM_CMP_VERSION < 150000
526#pragma GCC diagnostic pop
527#endif
528}
529
530} // close package namespace
531
532// FREE OPERATORS
533inline
534bool bdlc::operator==(const IndexClerkIter& lhs, const IndexClerkIter& rhs)
535{
536 return lhs.d_index_p == rhs.d_index_p;
537}
538
539inline
540bool bdlc::operator!=(const IndexClerkIter& lhs, const IndexClerkIter& rhs)
541{
542 return lhs.d_index_p != rhs.d_index_p;
543}
544
545namespace bdlc {
546
547 // ----------------
548 // class IndexClerk
549 // ----------------
550
551// CREATORS
552inline
554: d_unusedStack(basicAllocator)
555, d_nextNewIndex(0)
556{
557}
558
559inline
561 bslma::Allocator *basicAllocator)
562: d_unusedStack(original.d_unusedStack, basicAllocator)
563, d_nextNewIndex(original.d_nextNewIndex)
564{
565}
566
567inline
569{
570 BSLS_ASSERT_SAFE(areInvariantsPreserved(d_unusedStack, d_nextNewIndex));
571}
572
573// MANIPULATORS
574inline
576{
577 d_unusedStack = rhs.d_unusedStack;
578 d_nextNewIndex = rhs.d_nextNewIndex;
579 return *this;
580}
581
582inline
584{
585 if (d_unusedStack.empty()) {
586 return d_nextNewIndex++; // RETURN
587 }
588 else {
589 int index = d_unusedStack.back();
590 d_unusedStack.pop_back();
591 return index; // RETURN
592 }
593}
594
595inline
596void IndexClerk::putIndex(int index)
597{
598 BSLS_ASSERT(0 <= index);
599 BSLS_ASSERT( index < d_nextNewIndex);
601
602 d_unusedStack.push_back(index);
603}
604
605inline
607{
608 d_unusedStack.clear();
609 d_nextNewIndex = 0;
610}
611
612// Note: Order changed from declaration to make use of inlined 'removeAll'.
613
614template <class STREAM>
615STREAM& IndexClerk::bdexStreamIn(STREAM& stream, int version)
616{
617 switch (version) {
618 case 1: {
619 int nextNewIndex;
620 stream.getInt32(nextNewIndex);
621
622 if (!stream || nextNewIndex < 0) {
623 stream.invalidate();
624 return stream; // RETURN
625 }
626
627 bsl::vector<int> unusedStack;
628 bslx::InStreamFunctions::bdexStreamIn(stream, unusedStack, version);
629
630 // Stream can be invalidated after streaming in 'd_unusedStack'.
631
632 if (!stream || !areInvariantsPreserved(unusedStack, nextNewIndex)) {
633 stream.invalidate();
634 return stream; // RETURN
635 }
636
637 d_unusedStack = unusedStack;
638 d_nextNewIndex = nextNewIndex;
639 } break;
640 default: {
641 stream.invalidate();
642 } break;
643 }
644 return stream;
645}
646
647// ACCESSORS
648template <class STREAM>
649inline
650STREAM& IndexClerk::bdexStreamOut(STREAM& stream, int version) const
651{
652 if (stream) {
653 switch (version) { // switch on the schema version
654 case 1: {
655 stream.putInt32(d_nextNewIndex);
657 stream, d_unusedStack, version);
658 } break;
659 default: {
660 stream.invalidate(); // unrecognized version number
661 }
662 }
663 }
664 return stream;
665}
666
667inline
669{
670 return d_nextNewIndex - static_cast<int>(d_unusedStack.size());
671}
672
673inline
675{
676 return IndexClerkIter(d_unusedStack.begin() + d_unusedStack.size());
677}
678
679inline
681{
682 return IndexClerkIter(d_unusedStack.begin());
683}
684
685inline
687{
688 return static_cast<int>(d_unusedStack.size());
689}
690
691inline
693{
694 return d_nextNewIndex;
695}
696
697inline
698int IndexClerk::maxSupportedBdexVersion(int /* versionSelector */)
699{
700 return 1;
701}
702
703#ifndef BDE_OMIT_INTERNAL_DEPRECATED // pending deprecation
704
705// DEPRECATED METHODS
706inline
711
712#endif // BDE_OMIT_INTERNAL_DEPRECATED -- pending deprecation
713
714} // close package namespace
715
716// FREE OPERATORS
717inline
718bool bdlc::operator==(const IndexClerk& lhs, const IndexClerk& rhs)
719{
720 return lhs.d_nextNewIndex == rhs.d_nextNewIndex
721 && lhs.d_unusedStack == rhs.d_unusedStack;
722}
723
724inline
725bool bdlc::operator!=(const IndexClerk& lhs, const IndexClerk& rhs)
726{
727 return lhs.d_nextNewIndex != rhs.d_nextNewIndex
728 || lhs.d_unusedStack != rhs.d_unusedStack;
729}
730
731inline
732bsl::ostream& bdlc::operator<<(bsl::ostream& stream, const IndexClerk& rhs)
733{
734 return rhs.print(stream, 0, -1);
735}
736
737
738
739#endif
740
741// ----------------------------------------------------------------------------
742// Copyright 2018 Bloomberg Finance L.P.
743//
744// Licensed under the Apache License, Version 2.0 (the "License");
745// you may not use this file except in compliance with the License.
746// You may obtain a copy of the License at
747//
748// http://www.apache.org/licenses/LICENSE-2.0
749//
750// Unless required by applicable law or agreed to in writing, software
751// distributed under the License is distributed on an "AS IS" BASIS,
752// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
753// See the License for the specific language governing permissions and
754// limitations under the License.
755// ----------------------------- END-OF-FILE ----------------------------------
756
757/** @} */
758/** @} */
759/** @} */
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition bdlc_indexclerk.h:192
friend bool operator==(const IndexClerkIter &lhs, const IndexClerkIter &rhs)
IndexClerkIter & operator++()
Definition bdlc_indexclerk.h:494
IndexClerkIter & operator=(const IndexClerkIter &rhs)
Definition bdlc_indexclerk.h:487
IndexClerkIter()
Create an unbound iterator.
Definition bdlc_indexclerk.h:467
IndexClerkIter & operator--()
Definition bdlc_indexclerk.h:503
BSLMF_NESTED_TRAIT_DECLARATION(IndexClerkIter, bslmf::IsBitwiseCopyable)
friend bool operator!=(const IndexClerkIter &lhs, const IndexClerkIter &rhs)
int operator*() const
Definition bdlc_indexclerk.h:513
Definition bdlc_indexclerk.h:276
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
STREAM & bdexStreamIn(STREAM &stream, int version)
Definition bdlc_indexclerk.h:615
IndexClerk(bslma::Allocator *basicAllocator=0)
Definition bdlc_indexclerk.h:553
friend bool operator!=(const IndexClerk &, const IndexClerk &)
static int maxSupportedBdexVersion()
Definition bdlc_indexclerk.h:707
IndexClerk & operator=(const IndexClerk &rhs)
Definition bdlc_indexclerk.h:575
int getIndex()
Definition bdlc_indexclerk.h:583
void putIndex(int index)
Definition bdlc_indexclerk.h:596
BSLMF_NESTED_TRAIT_DECLARATION(IndexClerk, bslma::UsesBslmaAllocator)
IndexClerkIter end() const
Definition bdlc_indexclerk.h:680
int numDecommissionedIndices() const
Return the number of indices that are currently decommissioned.
Definition bdlc_indexclerk.h:686
int numCommissionedIndices() const
Return the number of indices currently in use.
Definition bdlc_indexclerk.h:668
void removeAll()
Definition bdlc_indexclerk.h:606
IndexClerkIter begin() const
Definition bdlc_indexclerk.h:674
bool isInUse(int index) const
STREAM & bdexStreamOut(STREAM &stream, int version) const
Definition bdlc_indexclerk.h:650
int nextNewIndex() const
Definition bdlc_indexclerk.h:692
~IndexClerk()
Destroy this index clerk.
Definition bdlc_indexclerk.h:568
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:2664
iterator begin() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_vector.h:2511
reference back()
Definition bslstl_vector.h:2577
bool empty() const BSLS_KEYWORD_NOEXCEPT
Return true if this vector has size 0, and false otherwise.
Definition bslstl_vector.h:2679
Definition bslstl_vector.h:1025
void push_back(const VALUE_TYPE &value)
Definition bslstl_vector.h:3760
void swap(vector &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits void clear() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_vector.h:1712
void pop_back()
Definition bslstl_vector.h:3792
Definition bslma_allocator.h:457
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdlc_bitarray.h:503
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)
STREAM & bdexStreamIn(STREAM &stream, VALUE_TYPE &variable)
Definition bslx_instreamfunctions.h:1247
STREAM & bdexStreamOut(STREAM &stream, const TYPE &value)
Definition bslx_outstreamfunctions.h:992
Definition bslma_usesbslmaallocator.h:343
Definition bslmf_isbitwisecopyable.h:298