8#ifndef INCLUDED_BSLALG_DEQUEITERATOR
9#define INCLUDED_BSLALG_DEQUEITERATOR
124#include <bslscm_version.h>
139template <
class VALUE_TYPE,
int BLOCK_LENGTH>
142template <
class VALUE_TYPE>
143class DequeIterator<VALUE_TYPE, 1>;
156template <
class VALUE_TYPE,
int BLOCK_LENGTH>
166 VALUE_TYPE *d_value_p;
178 return lhs.d_value_p == rhs.d_value_p;
181#ifdef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
187 auto result = lhs.d_blockPtr_p <=> rhs.d_blockPtr_p;
188 return result == 0 ? lhs.d_value_p <=> rhs.d_value_p
201 return lhs.d_value_p != rhs.d_value_p;
213 if (lhs.d_blockPtr_p == rhs.d_blockPtr_p) {
214 return lhs.d_value_p < rhs.d_value_p;
217 return lhs.d_blockPtr_p < rhs.d_blockPtr_p;
268 void setBlock(BlockPtr *blockPtrPtr);
336template <
class VALUE_TYPE>
346 VALUE_TYPE *d_value_p;
351 return lhs.d_blockPtr_p == rhs.d_blockPtr_p;
354#ifdef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
357 return lhs.d_blockPtr_p <=> rhs.d_blockPtr_p;
362 return lhs.d_blockPtr_p != rhs.d_blockPtr_p;
367 return lhs.d_blockPtr_p < rhs.d_blockPtr_p;
385 void setBlock(BlockPtr *blockPtrPtr);
411template <
class VALUE_TYPE,
int BLOCK_LENGTH>
419template <
class VALUE_TYPE,
int BLOCK_LENGTH>
422: d_blockPtr_p(blockPtrPtr)
423, d_value_p(reinterpret_cast<VALUE_TYPE*>(*blockPtrPtr))
427template <
class VALUE_TYPE,
int BLOCK_LENGTH>
430 VALUE_TYPE *valuePtr)
431: d_blockPtr_p(blockPtrPtr)
442template <
class VALUE_TYPE,
int BLOCK_LENGTH>
445 if (1 == this->remainingInBlock()) {
447 d_value_p = this->blockBegin();
454template <
class VALUE_TYPE,
int BLOCK_LENGTH>
457 if (0 == this->offsetInBlock()) {
459 d_value_p = this->blockEnd();
464template <
class VALUE_TYPE,
int BLOCK_LENGTH>
468 offset += offsetInBlock();
470 d_blockPtr_p += offset / BLOCK_LENGTH;
471 d_value_p = blockBegin() + (offset % BLOCK_LENGTH);
474 d_blockPtr_p -= (-offset - 1) / BLOCK_LENGTH + 1;
475 d_value_p = blockEnd() - ((-offset - 1) % BLOCK_LENGTH + 1);
479template <
class VALUE_TYPE,
int BLOCK_LENGTH>
484 this->operator+=(-offset);
487template <
class VALUE_TYPE,
int BLOCK_LENGTH>
492 d_value_p = this->blockBegin();
495template <
class VALUE_TYPE,
int BLOCK_LENGTH>
500 d_value_p = this->blockBegin();
503template <
class VALUE_TYPE,
int BLOCK_LENGTH>
507 d_blockPtr_p = blockPtrPtr;
508 d_value_p = this->blockBegin();
511template <
class VALUE_TYPE,
int BLOCK_LENGTH>
521template <
class VALUE_TYPE,
int BLOCK_LENGTH>
532template <
class VALUE_TYPE,
int BLOCK_LENGTH>
540template <
class VALUE_TYPE,
int BLOCK_LENGTH>
550template <
class VALUE_TYPE,
int BLOCK_LENGTH>
560template <
class VALUE_TYPE,
int BLOCK_LENGTH>
565 if (d_blockPtr_p == rhs.d_blockPtr_p) {
566 return d_value_p - rhs.d_value_p;
569 const int numFullBlocks =
static_cast<int>(
570 this->d_blockPtr_p - rhs.d_blockPtr_p - 1);
571 return (numFullBlocks * BLOCK_LENGTH +
576template <
class VALUE_TYPE,
int BLOCK_LENGTH>
581 return reinterpret_cast<VALUE_TYPE*
>(*d_blockPtr_p);
584template <
class VALUE_TYPE,
int BLOCK_LENGTH>
589 return reinterpret_cast<VALUE_TYPE*
>(*d_blockPtr_p) + BLOCK_LENGTH;
592template <
class VALUE_TYPE,
int BLOCK_LENGTH>
601template <
class VALUE_TYPE,
int BLOCK_LENGTH>
606 return d_value_p - blockBegin();
609template <
class VALUE_TYPE,
int BLOCK_LENGTH>
614 return blockBegin() + BLOCK_LENGTH - d_value_p;
617template <
class VALUE_TYPE,
int BLOCK_LENGTH>
630template <
class VALUE_TYPE>
638template <
class VALUE_TYPE>
641: d_blockPtr_p(blockPtrPtr)
642, d_value_p(reinterpret_cast<VALUE_TYPE*>(*blockPtrPtr))
646template <
class VALUE_TYPE>
649 VALUE_TYPE *valuePtr)
650: d_blockPtr_p(blockPtrPtr)
657template <
class VALUE_TYPE>
662 d_value_p =
reinterpret_cast<VALUE_TYPE*
>(*d_blockPtr_p);
665template <
class VALUE_TYPE>
670 d_value_p =
reinterpret_cast<VALUE_TYPE*
>(*d_blockPtr_p);
673template <
class VALUE_TYPE>
677 d_blockPtr_p += offset;
678 d_value_p =
reinterpret_cast<VALUE_TYPE*
>(*d_blockPtr_p);
681template <
class VALUE_TYPE>
685 this->operator+=(-offset);
688template <
class VALUE_TYPE>
693 d_value_p =
reinterpret_cast<VALUE_TYPE*
>(*d_blockPtr_p);
696template <
class VALUE_TYPE>
701 d_value_p =
reinterpret_cast<VALUE_TYPE*
>(*d_blockPtr_p);
704template <
class VALUE_TYPE>
708 d_blockPtr_p = blockPtrPtr;
709 d_value_p =
reinterpret_cast<VALUE_TYPE*
>(*d_blockPtr_p);
712template <
class VALUE_TYPE>
720template <
class VALUE_TYPE>
729template <
class VALUE_TYPE>
736template <
class VALUE_TYPE>
744template <
class VALUE_TYPE>
752template <
class VALUE_TYPE>
758 return d_blockPtr_p - rhs.d_blockPtr_p;
761template <
class VALUE_TYPE>
766 return reinterpret_cast<VALUE_TYPE*
>(*d_blockPtr_p);
769template <
class VALUE_TYPE>
774 return reinterpret_cast<VALUE_TYPE*
>(*d_blockPtr_p) + 1;
777template <
class VALUE_TYPE>
786template <
class VALUE_TYPE>
794template <
class VALUE_TYPE>
802template <
class VALUE_TYPE>
812#ifndef BDE_OPENSOURCE_PUBLICATION
817#ifdef bslalg_DequeIterator
818#undef bslalg_DequeIterator
821#define bslalg_DequeIterator bslalg::DequeIterator
833template <
class VALUE_TYPE,
int BLOCK_LENGTH>
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