BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslalg_dequeiterator.h
Go to the documentation of this file.
1/// @file bslalg_dequeiterator.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslalg_dequeiterator.h -*-C++-*-
8#ifndef INCLUDED_BSLALG_DEQUEITERATOR
9#define INCLUDED_BSLALG_DEQUEITERATOR
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bslalg_dequeiterator bslalg_dequeiterator
15/// @brief Provide a primitive iterator over deque data structures.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslalg
19/// @{
20/// @addtogroup bslalg_dequeiterator
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslalg_dequeiterator-purpose"> Purpose</a>
25/// * <a href="#bslalg_dequeiterator-classes"> Classes </a>
26/// * <a href="#bslalg_dequeiterator-description"> Description </a>
27/// * <a href="#bslalg_dequeiterator-usage"> Usage </a>
28///
29/// # Purpose {#bslalg_dequeiterator-purpose}
30/// Provide a primitive iterator over deque data structures.
31///
32/// # Classes {#bslalg_dequeiterator-classes}
33///
34/// - bslalg::DequeIterator: primitive iterator over a deque data structure
35///
36/// @see bslalg_dequeimputil, bslalg_dequeprimitives
37///
38/// # Description {#bslalg_dequeiterator-description}
39/// This component provides an in-core value semantic class,
40/// `bslalg::DequeIterator`, that is a primitive iterator type for enumerating
41/// elements in a deque (implemented in the form of a dynamic array) knowing
42/// only its value type and a nominal block size. Conceptually, a deque is an
43/// array of block pointers, each block capable of containing a fixed number of
44/// objects. An element in the deque is identified by an iterator that consists
45/// of two pointers:
46/// * a pointer to the block pointer array, and
47/// * a pointer to a value within the block referred to by the first pointer.
48///
49/// Dereferencing the iterator dereferences the second pointer. Incrementing or
50/// decrementing the iterator consists of incrementing the value pointer, unless
51/// the iterator crosses a block boundary in which case it must increment or
52/// decrement its pointer to the block pointer. Computing the distance between
53/// two iterators involves figuring out how many block are in between and how
54/// the offsets-in-block differ.
55///
56/// Note that an iterator is valid as long as the element it points to still
57/// belongs to the deque *and* there is no reallocation of the block pointer
58/// array. Inserting elements at either end of the deque usually maintains
59/// iterator validity, but inserting enough elements at the end of the queue
60/// might force the creating of sufficiently many blocks to trigger a
61/// reallocation of the block pointer array and invalidate all iterators into
62/// the deque; how many depends on the distances between the front and back of
63/// the deque and the first/last iterator in the block pointer array (19 in the
64/// picture below).
65///
66/// The picture is as follows:
67/// @code
68/// v--- Iterator to 'I': ptr to this BlockPtr
69/// +-----+-----+-----+-----+-----+-----+-----+-----+
70/// | * | * | * | * | * | * | * | * | BlockPtr array
71/// +-----+-----+--|--+--|--+--|--+--|--+-----+-----+
72/// | | | | Block
73/// | | | | +---+---+---+---+---+---+---+---+
74/// | | | `--| V | W | X | Y | Z | | | |
75/// | | | +---+---+---+---+---+---+---+---+
76/// | | | Block
77/// | | | +---+---+---+---+---+---+---+---+
78/// | | `--| N | O | P | Q | R | S | T | U |
79/// | | +---+---+---+---+---+---+---+---+
80/// | | v---- Iterator to 'I': ptr to value
81/// | | +---+---+---+---+---+---+---+---+
82/// | `--| F | G | H | I | J | K | L | M |
83/// | +---+---+---+---+---+---+---+---+
84/// | Block
85/// | +---+---+---+---+---+---+---+---+
86/// `--| | | | A | B | C | D | E |
87/// +---+---+---+---+---+---+---+---+
88/// @endcode
89/// Depicted above is a deque consisting of eight block pointers, only four
90/// actually used to point to blocks of eight elements. In the first block, the
91/// first three elements are uninitialized, and the twenty six elements follow
92/// in sequence across the different blocks. An iterator to the `I` element
93/// consists of a pointer to the fourth block pointer and a pointer to the sixth
94/// element of that block. The value of the corresponding deque would be
95/// `[ A, B, C, ... X, Y, Z ]`, its logical length 26, and its capacity would be
96/// 19 (the minimum number of prepend/append to force a reallocation of the
97/// block pointer array).
98///
99/// This component does not provide the full interface of a C++ standard library
100/// iterator as we do not want a dependency on `iterator_traits` in a package
101/// below `bslstl`. `bslalg::DequeIterator` provides the minimal necessary set
102/// of features to implement such an iterator for a standard conforming `deque`
103/// implementation in a higher level component.
104///
105/// ## Usage {#bslalg_dequeiterator-usage}
106///
107///
108/// This component is for use by the `bslstl` package. Other clients should use
109/// the STL deque (in header `<deque>`).
110/// @}
111/** @} */
112/** @} */
113
114/** @addtogroup bsl
115 * @{
116 */
117/** @addtogroup bslalg
118 * @{
119 */
120/** @addtogroup bslalg_dequeiterator
121 * @{
122 */
123
124#include <bslscm_version.h>
125
126#include <bslalg_dequeimputil.h>
127
129
130#include <bsls_assert.h>
132
133#include <cstddef> // std::size_t, std::ptrdiff_t
134
135
136
137namespace bslalg {
138
139template <class VALUE_TYPE, int BLOCK_LENGTH>
140class DequeIterator;
141
142template <class VALUE_TYPE>
143class DequeIterator<VALUE_TYPE, 1>;
144
145 // ===================
146 // class DequeIterator
147 // ===================
148
149/// Implementation of a deque iterator, parameterized by the `VALUE_TYPE`,
150/// for a deque with the parameterized `BLOCK_LENGTH`, and suitable for use
151/// by the `bslstl::RandomAccessIterator` adapter. Note that `BLOCK_LENGTH`
152/// is the number of items of `VALUE_TYPE` within a block, not the size of a
153/// block in bytes.
154///
155/// See @ref bslalg_dequeiterator
156template <class VALUE_TYPE, int BLOCK_LENGTH>
158
159 // PRIVATE TYPES
161 typedef typename DequeImpUtil::BlockPtr BlockPtr;
163
164 // DATA
165 BlockPtr *d_blockPtr_p;
166 VALUE_TYPE *d_value_p;
167
168 // FRIENDS
169
170 /// Return `true` if the specified `lhs` iterator points to the same
171 /// element in the same block as the specified `rhs` iterator, and
172 /// `false` otherwise. The behavior is undefined unless `lhs` and `rhs`
173 /// are iterators over the same deque. Note that this friend is a
174 /// regular functon, not a function template, so there is no way to
175 /// declare it outside the class in order to provide the definition.
176 friend bool operator==(const DequeIterator& lhs, const DequeIterator& rhs)
177 {
178 return lhs.d_value_p == rhs.d_value_p;
179 }
180
181#ifdef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
182 /// Perform a three-way comparison between the specified `lhs` and `rhs`
183 /// iterators. The behavior is undefined unless `lhs` and `rhs` are
184 /// iterators over the same deque.
185 friend auto operator<=>(const DequeIterator& lhs, const DequeIterator& rhs)
186 {
187 auto result = lhs.d_blockPtr_p <=> rhs.d_blockPtr_p;
188 return result == 0 ? lhs.d_value_p <=> rhs.d_value_p
189 : result;
190 }
191#else
192 /// Return `true` if the specified `lhs` iterator points to a different
193 /// element in the same block as the specified `rhs` iterator, or points
194 /// to an element in a different block to the `rhs` iterator, and
195 /// `false` otherwise. The behavior is undefined unless `lhs` and `rhs`
196 /// are iterators over the same deque. Note that this friend is a
197 /// regular functon, not a function template, so there is no way to
198 /// declare it outside the class in order to provide the definition.
199 friend bool operator!=(const DequeIterator& lhs, const DequeIterator& rhs)
200 {
201 return lhs.d_value_p != rhs.d_value_p;
202 }
203
204 /// Return `true` if the specified `lhs` iterator points to an element
205 /// in a previous block or in a previous position in the same block as
206 /// the specified `rhs` iterator, and `false` otherwise. The behavior
207 /// is undefined unless `lhs` and `rhs` are iterators over the same
208 /// deque. Note that this friend is a regular functon, not a function
209 /// template, so there is no way to declare it outside the class in
210 /// order to provide the definition.
211 friend bool operator<(const DequeIterator& lhs, const DequeIterator& rhs)
212 {
213 if (lhs.d_blockPtr_p == rhs.d_blockPtr_p) {
214 return lhs.d_value_p < rhs.d_value_p; // RETURN
215 }
216 else {
217 return lhs.d_blockPtr_p < rhs.d_blockPtr_p; // RETURN
218 }
219 }
220#endif
221
222 public:
223 // CREATORS
224
225 /// Create a singular iterator (i.e., having internal null pointers).
227
228 /// Create an iterator pointing to the first element in the block
229 /// pointed to by the specified `blockPtrPtr`.
230 explicit
231 DequeIterator(BlockPtr *blockPtrPtr);
232
233 /// Create an iterator pointing to the element at the specified
234 /// `valuePtr` address in the block pointed to by the specified
235 /// `blockPtrPtr`. The behavior is undefined unless `valuePtr` points
236 /// into the block `*blockPtrPtr`.
237 DequeIterator(BlockPtr *blockPtrPtr, VALUE_TYPE *valuePtr);
238
239 // MANIPULATORS
240
241 /// Increment this iterator to point to the next element in the
242 /// corresponding deque (i.e., the element following the current one in
243 /// the same block or, if the current element is the last one in the
244 /// block, the first element in the next block).
245 void operator++();
246
247 /// Decrement this iterator to point to the previous element in the
248 /// corresponding deque (i.e., the element preceding the current one in
249 /// the same block or, if the current element is the first one in the
250 /// block, the last element in the previous block).
251 void operator--();
252
253 /// Advance this iterator by the specified `offset`.
254 void operator+=(std::ptrdiff_t offset);
255
256 /// Move this iterator backward by the specified `offset`.
257 void operator-=(std::ptrdiff_t offset);
258
259 /// Set this iterator to point to the first element of the next block.
260 void nextBlock();
261
262 /// Set this iterator to point to the first (not the last) element of
263 /// the previous block.
264 void previousBlock();
265
266 /// Set this iterator to point to the first element of the block pointed
267 /// to by the specified `blockPtrPtr`.
268 void setBlock(BlockPtr *blockPtrPtr);
269
270 /// Decrement this iterator to point to the next element in the block of
271 /// the corresponding deque. The behavior is undefined unless this
272 /// iterator is pointed to a valid position of the deque. Note that
273 /// this method is used only for optimization purposes in
274 /// `bslstl_Deque`, and clients of this package should not use this
275 /// directly.
276 void valuePtrDecrement();
277
278 /// Increment this iterator to point to the next element in the block of
279 /// the corresponding deque. The behavior is undefined unless this
280 /// iterator is pointed to a valid position of the deque. Note that
281 /// this method is used only for optimization purposes in
282 /// `bslstl_Deque`, and clients of this package should not use this
283 /// directly.
284 void valuePtrIncrement();
285
286 // ACCESSORS
287
288 /// Return a reference to the parameterized `VALUE_TYPE` object pointed
289 /// to by this iterator. Note that this value is modifiable if
290 /// `VALUE_TYPE` is modifiable, and non-modifiable if it is not.
291 VALUE_TYPE& operator*() const;
292
293 /// Return an iterator pointing the element at the specified `offset`
294 /// after this iterator.
295 DequeIterator operator+(std::ptrdiff_t offset) const;
296
297 /// Return an iterator pointing the element at the specified `offset`
298 /// before this iterator.
299 DequeIterator operator-(std::ptrdiff_t offset) const;
300
301 /// Return the distance between this iterator and the specified `rhs`
302 /// iterator.
303 std::ptrdiff_t operator-(const DequeIterator& rhs) const;
304
305 /// Return the address of the first element in the block pointed to by
306 /// this iterator.
307 VALUE_TYPE *blockBegin() const;
308
309 /// Return the address of (one-past) the last element in the block
310 /// pointed to by this iterator.
311 VALUE_TYPE *blockEnd() const;
312
313 /// Return the address of the block pointer pointed to by this iterator.
314 BlockPtr *blockPtr() const;
315
316 /// Return the offset of the element pointed to by this iterator, from
317 /// the beginning of the block containing it.
318 std::size_t offsetInBlock() const;
319
320 /// Return the number of elements in the block pointed to by this
321 /// iterator, until the end of this block, starting at (and including)
322 /// the element pointed to by this iterator.
323 std::size_t remainingInBlock() const;
324
325 /// Return the address of the parameterized `VALUE_TYPE` object pointed
326 /// to by this iterator.
327 VALUE_TYPE *valuePtr() const;
328};
329
330// PARTIAL SPECIALIZATION
331
332/// This partial specialization of `DequeIterator` for the case when there
333/// is a single element per block uses simpler storage and a simpler
334/// implementation. The contract for all functions is the same, and so not
335/// repeated.
336template <class VALUE_TYPE>
337class DequeIterator<VALUE_TYPE, 1> {
338
339 // PRIVATE TYPES
341 typedef typename DequeImpUtil::BlockPtr BlockPtr;
343
344 // DATA
345 BlockPtr *d_blockPtr_p; // pointer to BlockPtr within BlockPtr array
346 VALUE_TYPE *d_value_p; // pointer to element referenced by iterator
347
348 // FRIENDS
349 friend bool operator==(const DequeIterator& lhs, const DequeIterator& rhs)
350 {
351 return lhs.d_blockPtr_p == rhs.d_blockPtr_p;
352 }
353
354#ifdef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
355 friend auto operator<=>(const DequeIterator& lhs, const DequeIterator& rhs)
356 {
357 return lhs.d_blockPtr_p <=> rhs.d_blockPtr_p;
358 }
359#else
360 friend bool operator!=(const DequeIterator& lhs, const DequeIterator& rhs)
361 {
362 return lhs.d_blockPtr_p != rhs.d_blockPtr_p;
363 }
364
365 friend bool operator<(const DequeIterator& lhs, const DequeIterator& rhs)
366 {
367 return lhs.d_blockPtr_p < rhs.d_blockPtr_p;
368 }
369#endif
370
371 public:
372 // CREATORS
374 DequeIterator(BlockPtr *blockPtrPtr);
375 DequeIterator(BlockPtr *blockPtrPtr, VALUE_TYPE *valuePtr);
376
377 // MANIPULATORS
378 void operator++();
379 void operator--();
380 void operator+=(std::ptrdiff_t offset);
381 void operator-=(std::ptrdiff_t offset);
382
383 void nextBlock();
384 void previousBlock();
385 void setBlock(BlockPtr *blockPtrPtr);
386 void valuePtrDecrement();
387 void valuePtrIncrement();
388
389 // ACCESSORS
390 VALUE_TYPE& operator*() const;
391 DequeIterator operator+(std::ptrdiff_t offset) const;
392 DequeIterator operator-(std::ptrdiff_t offset) const;
393 std::ptrdiff_t operator-(const DequeIterator& rhs) const;
394 VALUE_TYPE *blockBegin() const;
395 VALUE_TYPE *blockEnd() const;
396 BlockPtr *blockPtr() const;
397 std::size_t offsetInBlock() const;
398 std::size_t remainingInBlock() const;
399 VALUE_TYPE *valuePtr() const;
400};
401
402// ============================================================================
403// INLINE FUNCTION DEFINITIONS
404// ============================================================================
405
406 // -------------------
407 // class DequeIterator
408 // -------------------
409
410// CREATORS
411template <class VALUE_TYPE, int BLOCK_LENGTH>
412inline
414: d_blockPtr_p(0)
415, d_value_p(0)
416{
417}
418
419template <class VALUE_TYPE, int BLOCK_LENGTH>
420inline
422: d_blockPtr_p(blockPtrPtr)
423, d_value_p(reinterpret_cast<VALUE_TYPE*>(*blockPtrPtr))
424{
425}
426
427template <class VALUE_TYPE, int BLOCK_LENGTH>
428inline
430 VALUE_TYPE *valuePtr)
431: d_blockPtr_p(blockPtrPtr)
432, d_value_p(valuePtr)
433{
434 // Trivially true, or undefined behavior, without the cast.
436 reinterpret_cast<bsls::Types::UintPtr>((void*)blockPtrPtr[0]->d_data)
437 <= reinterpret_cast<bsls::Types::UintPtr>((void*)valuePtr));
438 BSLS_ASSERT_SAFE(valuePtr - blockPtrPtr[0]->d_data < BLOCK_LENGTH);
439}
440
441// MANIPULATORS
442template <class VALUE_TYPE, int BLOCK_LENGTH>
444{
445 if (1 == this->remainingInBlock()) {
446 ++d_blockPtr_p;
447 d_value_p = this->blockBegin();
448 }
449 else {
450 ++d_value_p;
451 }
452}
453
454template <class VALUE_TYPE, int BLOCK_LENGTH>
456{
457 if (0 == this->offsetInBlock()) {
458 --d_blockPtr_p;
459 d_value_p = this->blockEnd();
460 }
461 --d_value_p;
462}
463
464template <class VALUE_TYPE, int BLOCK_LENGTH>
465void
467{
468 offset += offsetInBlock();
469 if (offset >= 0) {
470 d_blockPtr_p += offset / BLOCK_LENGTH;
471 d_value_p = blockBegin() + (offset % BLOCK_LENGTH);
472 }
473 else {
474 d_blockPtr_p -= (-offset - 1) / BLOCK_LENGTH + 1;
475 d_value_p = blockEnd() - ((-offset - 1) % BLOCK_LENGTH + 1);
476 }
477}
478
479template <class VALUE_TYPE, int BLOCK_LENGTH>
480inline
481void
483{
484 this->operator+=(-offset);
485}
486
487template <class VALUE_TYPE, int BLOCK_LENGTH>
488inline
490{
491 ++d_blockPtr_p;
492 d_value_p = this->blockBegin();
493}
494
495template <class VALUE_TYPE, int BLOCK_LENGTH>
496inline
498{
499 --d_blockPtr_p;
500 d_value_p = this->blockBegin();
501}
502
503template <class VALUE_TYPE, int BLOCK_LENGTH>
504inline
506{
507 d_blockPtr_p = blockPtrPtr;
508 d_value_p = this->blockBegin();
509}
510
511template <class VALUE_TYPE, int BLOCK_LENGTH>
512inline
514{
515 BSLS_ASSERT_SAFE(d_blockPtr_p[0]->d_data <= d_value_p);
516 BSLS_ASSERT_SAFE(d_value_p < d_blockPtr_p[0]->d_data + BLOCK_LENGTH);
517
518 --d_value_p;
519}
520
521template <class VALUE_TYPE, int BLOCK_LENGTH>
522inline
524{
525 BSLS_ASSERT_SAFE(d_blockPtr_p[0]->d_data <= d_value_p);
526 BSLS_ASSERT_SAFE(d_value_p < d_blockPtr_p[0]->d_data + BLOCK_LENGTH);
527
528 ++d_value_p;
529}
530
531// ACCESSORS
532template <class VALUE_TYPE, int BLOCK_LENGTH>
533inline
534VALUE_TYPE&
536{
537 return *d_value_p;
538}
539
540template <class VALUE_TYPE, int BLOCK_LENGTH>
541inline
544{
545 DequeIterator ret(*this);
546 ret += offset;
547 return ret;
548}
549
550template <class VALUE_TYPE, int BLOCK_LENGTH>
551inline
554{
555 DequeIterator ret(*this);
556 ret += -offset;
557 return ret;
558}
559
560template <class VALUE_TYPE, int BLOCK_LENGTH>
561std::ptrdiff_t
564{
565 if (d_blockPtr_p == rhs.d_blockPtr_p) {
566 return d_value_p - rhs.d_value_p; // RETURN
567 }
568 else {
569 const int numFullBlocks = static_cast<int>(
570 this->d_blockPtr_p - rhs.d_blockPtr_p - 1);
571 return (numFullBlocks * BLOCK_LENGTH +
572 rhs.remainingInBlock() + this->offsetInBlock()); // RETURN
573 }
574}
575
576template <class VALUE_TYPE, int BLOCK_LENGTH>
577inline
578VALUE_TYPE *
580{
581 return reinterpret_cast<VALUE_TYPE*>(*d_blockPtr_p);
582}
583
584template <class VALUE_TYPE, int BLOCK_LENGTH>
585inline
586VALUE_TYPE *
588{
589 return reinterpret_cast<VALUE_TYPE*>(*d_blockPtr_p) + BLOCK_LENGTH;
590}
591
592template <class VALUE_TYPE, int BLOCK_LENGTH>
593inline
594typename
597{
598 return d_blockPtr_p;
599}
600
601template <class VALUE_TYPE, int BLOCK_LENGTH>
602inline
603std::size_t
605{
606 return d_value_p - blockBegin();
607}
608
609template <class VALUE_TYPE, int BLOCK_LENGTH>
610inline
611std::size_t
613{
614 return blockBegin() + BLOCK_LENGTH - d_value_p;
615}
616
617template <class VALUE_TYPE, int BLOCK_LENGTH>
618inline
619VALUE_TYPE *
621{
622 return d_value_p;
623}
624
625 // ---------------------------------
626 // class DequeIterator<VALUE_TYPE,1>
627 // ---------------------------------
628
629// CREATORS
630template <class VALUE_TYPE>
631inline
633: d_blockPtr_p(0)
634, d_value_p(0)
635{
636}
637
638template <class VALUE_TYPE>
639inline
641: d_blockPtr_p(blockPtrPtr)
642, d_value_p(reinterpret_cast<VALUE_TYPE*>(*blockPtrPtr))
643{
644}
645
646template <class VALUE_TYPE>
647inline
649 VALUE_TYPE *valuePtr)
650: d_blockPtr_p(blockPtrPtr)
651, d_value_p(valuePtr)
652{
653 BSLS_ASSERT_SAFE((*blockPtrPtr)->d_data == valuePtr);
654}
655
656// MANIPULATORS
657template <class VALUE_TYPE>
658inline
660{
661 ++d_blockPtr_p;
662 d_value_p = reinterpret_cast<VALUE_TYPE*>(*d_blockPtr_p);
663}
664
665template <class VALUE_TYPE>
666inline
668{
669 --d_blockPtr_p;
670 d_value_p = reinterpret_cast<VALUE_TYPE*>(*d_blockPtr_p);
671}
672
673template <class VALUE_TYPE>
674inline
676{
677 d_blockPtr_p += offset;
678 d_value_p = reinterpret_cast<VALUE_TYPE*>(*d_blockPtr_p);
679}
680
681template <class VALUE_TYPE>
682inline
684{
685 this->operator+=(-offset);
686}
687
688template <class VALUE_TYPE>
689inline
691{
692 ++d_blockPtr_p;
693 d_value_p = reinterpret_cast<VALUE_TYPE*>(*d_blockPtr_p);
694}
695
696template <class VALUE_TYPE>
697inline
699{
700 --d_blockPtr_p;
701 d_value_p = reinterpret_cast<VALUE_TYPE*>(*d_blockPtr_p);
702}
703
704template <class VALUE_TYPE>
705inline
707{
708 d_blockPtr_p = blockPtrPtr;
709 d_value_p = reinterpret_cast<VALUE_TYPE*>(*d_blockPtr_p);
710}
711
712template <class VALUE_TYPE>
713inline
715{
716 // This should never be called for 'BLOCK_LENGTH' of 1
718}
719
720template <class VALUE_TYPE>
721inline
723{
724 // This should never be called for 'BLOCK_LENGTH' of 1
726}
727
728// ACCESSORS
729template <class VALUE_TYPE>
730inline
732{
733 return *d_value_p;
734}
735
736template <class VALUE_TYPE>
737inline
739DequeIterator<VALUE_TYPE, 1>::operator+(std::ptrdiff_t offset) const
740{
741 return DequeIterator<VALUE_TYPE, 1>(d_blockPtr_p + offset);
742}
743
744template <class VALUE_TYPE>
745inline
747DequeIterator<VALUE_TYPE, 1>::operator-(std::ptrdiff_t offset) const
748{
749 return DequeIterator<VALUE_TYPE, 1>(d_blockPtr_p - offset);
750}
751
752template <class VALUE_TYPE>
753inline
754std::ptrdiff_t
756 const DequeIterator<VALUE_TYPE, 1>& rhs) const
757{
758 return d_blockPtr_p - rhs.d_blockPtr_p;
759}
760
761template <class VALUE_TYPE>
762inline
763VALUE_TYPE *
765{
766 return reinterpret_cast<VALUE_TYPE*>(*d_blockPtr_p);
767}
768
769template <class VALUE_TYPE>
770inline
771VALUE_TYPE *
773{
774 return reinterpret_cast<VALUE_TYPE*>(*d_blockPtr_p) + 1;
775}
776
777template <class VALUE_TYPE>
778inline
779typename
782{
783 return d_blockPtr_p;
784}
785
786template <class VALUE_TYPE>
787inline
788std::size_t
790{
791 return 0;
792}
793
794template <class VALUE_TYPE>
795inline
796std::size_t
801
802template <class VALUE_TYPE>
803inline
804VALUE_TYPE *
806{
807 return d_value_p;
808}
809
810} // close package namespace
811
812#ifndef BDE_OPENSOURCE_PUBLICATION // BACKWARD_COMPATIBILITY
813// ============================================================================
814// BACKWARD COMPATIBILITY
815// ============================================================================
816
817#ifdef bslalg_DequeIterator
818#undef bslalg_DequeIterator
819#endif
820/// This alias is defined for backward compatibility.
821#define bslalg_DequeIterator bslalg::DequeIterator
822#endif // BDE_OPENSOURCE_PUBLICATION -- BACKWARD_COMPATIBILITY
823
824
825
826// ============================================================================
827// TYPE TRAITS
828// ============================================================================
829
830
831namespace bslmf {
832
833template <class VALUE_TYPE, int BLOCK_LENGTH>
834struct IsBitwiseCopyable<BloombergLP::bslalg::DequeIterator<VALUE_TYPE,
835 BLOCK_LENGTH> >
837{};
838
839} // close namespace bslmf
840
841
842#endif
843
844// ----------------------------------------------------------------------------
845// Copyright 2013 Bloomberg Finance L.P.
846//
847// Licensed under the Apache License, Version 2.0 (the "License");
848// you may not use this file except in compliance with the License.
849// You may obtain a copy of the License at
850//
851// http://www.apache.org/licenses/LICENSE-2.0
852//
853// Unless required by applicable law or agreed to in writing, software
854// distributed under the License is distributed on an "AS IS" BASIS,
855// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
856// See the License for the specific language governing permissions and
857// limitations under the License.
858// ----------------------------- END-OF-FILE ----------------------------------
859
860/** @} */
861/** @} */
862/** @} */
Definition bslalg_dequeiterator.h:337
std::ptrdiff_t operator-(const DequeIterator &rhs) const
friend bool operator<(const DequeIterator &lhs, const DequeIterator &rhs)
Definition bslalg_dequeiterator.h:365
friend bool operator!=(const DequeIterator &lhs, const DequeIterator &rhs)
Definition bslalg_dequeiterator.h:360
friend bool operator==(const DequeIterator &lhs, const DequeIterator &rhs)
Definition bslalg_dequeiterator.h:349
Definition bslalg_dequeiterator.h:157
void previousBlock()
Definition bslalg_dequeiterator.h:497
std::size_t offsetInBlock() const
Definition bslalg_dequeiterator.h:604
std::size_t remainingInBlock() const
Definition bslalg_dequeiterator.h:612
void setBlock(BlockPtr *blockPtrPtr)
Definition bslalg_dequeiterator.h:505
void valuePtrDecrement()
Definition bslalg_dequeiterator.h:513
VALUE_TYPE * valuePtr() const
Definition bslalg_dequeiterator.h:620
void nextBlock()
Set this iterator to point to the first element of the next block.
Definition bslalg_dequeiterator.h:489
void valuePtrIncrement()
Definition bslalg_dequeiterator.h:523
void operator-=(std::ptrdiff_t offset)
Move this iterator backward by the specified offset.
Definition bslalg_dequeiterator.h:482
void operator+=(std::ptrdiff_t offset)
Advance this iterator by the specified offset.
Definition bslalg_dequeiterator.h:466
friend bool operator<(const DequeIterator &lhs, const DequeIterator &rhs)
Definition bslalg_dequeiterator.h:211
void operator--()
Definition bslalg_dequeiterator.h:455
DequeIterator operator-(std::ptrdiff_t offset) const
Definition bslalg_dequeiterator.h:553
friend bool operator!=(const DequeIterator &lhs, const DequeIterator &rhs)
Definition bslalg_dequeiterator.h:199
void operator++()
Definition bslalg_dequeiterator.h:443
BlockPtr * blockPtr() const
Return the address of the block pointer pointed to by this iterator.
Definition bslalg_dequeiterator.h:596
friend bool operator==(const DequeIterator &lhs, const DequeIterator &rhs)
Definition bslalg_dequeiterator.h:176
VALUE_TYPE * blockBegin() const
Definition bslalg_dequeiterator.h:579
VALUE_TYPE & operator*() const
Definition bslalg_dequeiterator.h:535
DequeIterator()
Create a singular iterator (i.e., having internal null pointers).
Definition bslalg_dequeiterator.h:413
VALUE_TYPE * blockEnd() const
Definition bslalg_dequeiterator.h:587
DequeIterator operator+(std::ptrdiff_t offset) const
Definition bslalg_dequeiterator.h:543
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdlc_flathashmap.h:1805
Definition bdlbb_blob.h:576
Definition bslalg_dequeimputil.h:143
Definition bslalg_dequeimputil.h:124
Definition bslmf_isbitwisecopyable.h:298
std::size_t UintPtr
Definition bsls_types.h:126