61#ifndef __ADS_DualArrayDeque
62 #define __ADS_DualArrayDeque
73#include <initializer_list>
90template<
class T ,
class S = std::vector< T > >
113 [[nodiscard]]
bool empty(
void )
const {
114 return( ( f_F.size() == 0 ) && ( f_B.size() == 0 ) );
118 [[nodiscard]] std::size_t
size(
void )
const {
119 return( f_F.size() + f_B.size() );
132 [[nodiscard]]
const T &
front(
void )
const {
return( ( *
this )[ 0 ] ); }
136 [[nodiscard]]
const T &
back(
void )
const {
137 return( ( *
this )[
size() - 1 ] );
155 void insert( std::size_t i ,
const T & x );
180 const std::size_t i = rankOf( p );
182 return(
begin() + std::ptrdiff_t( i ) );
188 template< std::input_iterator I , std::sentinel_for< I > E >
190 const std::size_t i0 = rankOf( p );
191 for( std::size_t i = i0 ; first != last ; ++first )
192 insert( i++ , T( *first ) );
193 return(
begin() + std::ptrdiff_t( i0 ) );
197 template<
class... A >
199 return(
insert( p , T( std::forward< A >( a )... ) ) );
206 const std::size_t i = rankOf( p );
208 return(
begin() + std::ptrdiff_t( i ) );
214 const std::size_t i = rankOf( first );
215 for( std::size_t k = rankOf( last ) - i ; k > 0 ; --k )
217 return(
begin() + std::ptrdiff_t( i ) );
256 [[nodiscard]] std::size_t
frontSize(
void )
const {
return( f_F.size() ); }
282 return( std::size_t( p -
begin() ) );
286 static void put( S & s , std::size_t j , T && x );
289 static void take( S & s , std::size_t j );
316 void balance(
void );
322 static void deal( S &
big , S & small , std::size_t t );
325 [[nodiscard]]
bool balanced(
void )
const;
340#include "ADS/sequence/impl/DualArrayDeque.tpp"
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The iterators that the containers of the library have in common, beyond the book: they give a contain...
std::size_t frontSize(void) const
the number of items of the front stack
Definition DualArrayDeque.h:256
iterator erase(const_iterator first, const_iterator last)
the items of removed, one erase( i ) each; an iterator on the item after them
Definition DualArrayDeque.h:213
const_iterator cbegin(void) const
the constant iterator on the first item
Definition DualArrayDeque.h:274
void insert(std::size_t i, const T &x)
puts at the rank , in amortized time
std::size_t size(void) const
the number of items
Definition DualArrayDeque.h:118
RankIterator< DualArrayDeque, T, false > iterator
the iterator on the items
Definition DualArrayDeque.h:102
T & operator[](std::size_t i)
the item of rank
const T & front(void) const
the first item
Definition DualArrayDeque.h:132
bool empty(void) const
true if there is no item
Definition DualArrayDeque.h:113
iterator insert(const_iterator p, const T &x)
before the item of , i.e., insert( i , x ) with the rank of : the members by iterator of a SequenceC...
Definition DualArrayDeque.h:179
void clear(void)
removes all the items
const_iterator begin(void) const
the constant iterator on the first item
Definition DualArrayDeque.h:266
const T & back(void) const
the last item
Definition DualArrayDeque.h:136
bool operator==(const DualArrayDeque &o) const
the same items in the same order
const_iterator cend(void) const
the constant iterator past the last item
Definition DualArrayDeque.h:276
const T & const_reference
a constant reference
Definition DualArrayDeque.h:100
DualArrayDeque(void)=default
the empty deque
iterator erase(const_iterator p)
the item of removed, i.e., erase( i ) with its rank; an iterator on the item after it
Definition DualArrayDeque.h:205
iterator end(void)
the iterator past the last item
Definition DualArrayDeque.h:264
void rotate(std::size_t r)
the item of rank moved to the rank , in amortized time (exercise 2.5 of Morin's book)
RankIterator< DualArrayDeque, T, true > const_iterator
the iterator on the constant items
Definition DualArrayDeque.h:104
T value_type
the type of the items
Definition DualArrayDeque.h:96
void push_front(const T &x)
at the front, insert( 0 , x )
Definition DualArrayDeque.h:221
const_iterator end(void) const
the constant iterator past the last item
Definition DualArrayDeque.h:270
iterator begin(void)
the iterator on the first item
Definition DualArrayDeque.h:262
std::ptrdiff_t difference_type
the type of the distances
Definition DualArrayDeque.h:98
iterator emplace(const_iterator p, A &&... a)
an item built from before the item of
Definition DualArrayDeque.h:198
std::size_t size_type
the type of the sizes
Definition DualArrayDeque.h:97
void pop_back(void)
removes the last item
Definition DualArrayDeque.h:232
void erase(std::size_t i)
removes the item of rank , in amortized time
const T & operator[](std::size_t i) const
the item of rank , constant
DualArrayDeque(std::initializer_list< T > l)
the items of l, in order
void pop_front(void)
removes the first item
Definition DualArrayDeque.h:228
iterator insert(const_iterator p, I first, E last)
the items of before the item of , in their order, one insert( i , x ) each; an iterator on the first...
Definition DualArrayDeque.h:189
T & reference
a reference to an item
Definition DualArrayDeque.h:99
void push_back(const T &x)
at the back, insert( size() , x )
Definition DualArrayDeque.h:224
the random-access iterator on the items of a container C read by rank, c[ i ] the item ,...
Definition Iterators.h:392
@ big
the most significant byte first
Definition Persistence.h:121