68#ifndef __ADS_RootishArrayStack
69 #define __ADS_RootishArrayStack
82#include <initializer_list>
102template<
class T ,
class A = std::allocator< T > >
149 requires detail::alwaysEqualAlloc< A >;
153 requires( ! detail::alwaysEqualAlloc< A > )
155 return( detail::copyAssign( *
this , o ) );
161 requires( ! detail::alwaysEqualAlloc< A > )
163 return( detail::moveAssign( *
this , std::move( o ) ) );
175 [[nodiscard]]
bool empty(
void )
const {
return( f_n == 0 ); }
178 [[nodiscard]] std::size_t
size(
void )
const {
return( f_n ); }
182 return( f_blocks.size() * ( f_blocks.size() + 1 ) / 2 );
186 [[nodiscard]] std::size_t
blocks(
void )
const {
return( f_blocks.size() ); }
203 [[nodiscard]]
static std::size_t
block( std::size_t i );
215 [[nodiscard]]
const T &
front(
void )
const;
219 [[nodiscard]]
const T &
back(
void )
const;
238 void insert( std::size_t i ,
const T & x );
264 const std::size_t i = rankOf( p );
266 return(
begin() + std::ptrdiff_t( i ) );
272 template< std::input_iterator I , std::sentinel_for< I > E >
274 const std::size_t i0 = rankOf( p );
275 for( std::size_t i = i0 ; first != last ; ++first )
276 insert( i++ , T( *first ) );
277 return(
begin() + std::ptrdiff_t( i0 ) );
281 template<
class... Args >
283 return(
insert( p , T( std::forward< Args >( a )... ) ) );
290 const std::size_t i = rankOf( p );
292 return(
begin() + std::ptrdiff_t( i ) );
298 const std::size_t i = rankOf( first );
299 for( std::size_t k = rankOf( last ) - i ; k > 0 ; --k )
301 return(
begin() + std::ptrdiff_t( i ) );
311 template<
class... Args >
345 return( std::size_t( p -
begin() ) );
349 [[nodiscard]] T * place( std::size_t i )
const;
358 [[nodiscard]]
bool fits(
void )
const;
361 using Alloc = detail::RebindAlloc< A , T >;
362 using Traits = std::allocator_traits< Alloc >;
365 detail::AllocVector< A , T * > f_blocks;
378#include "ADS/sequence/impl/RootishArrayStack.tpp"
The rules of the allocator-aware containers of the standard ([container.reqmts], [allocator....
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...
the random-access iterator on the items of a container C read by rank, c[ i ] the item ,...
Definition Iterators.h:392
const_iterator end(void) const
the constant iterator past the last item
Definition RootishArrayStack.h:333
void pop_back(void)
removes the last item
Definition RootishArrayStack.h:316
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 RootishArrayStack.h:263
void clear(void)
removes all the items and frees the blocks
RootishArrayStack(void)=default
the empty list, with no block
T & emplace_back(Args &&... args)
the item built from args at the end, amortized
iterator end(void)
the iterator past the last item
Definition RootishArrayStack.h:327
~RootishArrayStack()
destroys the items and frees the blocks
bool operator==(const RootishArrayStack &o) const
the same items in the same order
RootishArrayStack(RootishArrayStack &&o, const A &alloc)
the items of o, which is left empty, on alloc: its blocks if the allocators are equal,...
RootishArrayStack(const A &alloc)
the empty sequence, its blocks from alloc
Definition RootishArrayStack.h:128
bool empty(void) const
true if there is no item
Definition RootishArrayStack.h:175
const_iterator cbegin(void) const
the constant iterator on the first item
Definition RootishArrayStack.h:337
std::size_t size(void) const
the number of items
Definition RootishArrayStack.h:178
const_iterator cend(void) const
the constant iterator past the last item
Definition RootishArrayStack.h:339
A allocator_type
the type of the allocator
Definition RootishArrayStack.h:118
RootishArrayStack(const RootishArrayStack &o, const A &alloc)
a copy of o, on alloc
RootishArrayStack(std::initializer_list< T > l)
the items of l, in order
iterator emplace(const_iterator p, Args &&... a)
an item built from before the item of
Definition RootishArrayStack.h:282
RankIterator< RootishArrayStack, T, true > const_iterator
the iterator on the constant items
Definition RootishArrayStack.h:116
iterator begin(void)
the iterator on the first item
Definition RootishArrayStack.h:325
const T & back(void) const
the last item
void push_back(const T &x)
at the end, insert( size() , x )
Definition RootishArrayStack.h:305
const_iterator begin(void) const
the constant iterator on the first item
Definition RootishArrayStack.h:329
const T & operator[](std::size_t i) const
the item of rank , constant
iterator erase(const_iterator p)
the item of removed, i.e., erase( i ) with its rank; an iterator on the item after it
Definition RootishArrayStack.h:289
std::size_t size_type
the type of the sizes
Definition RootishArrayStack.h:109
RootishArrayStack & operator=(RootishArrayStack o) noexcept
the items of o, by copy and swap, when the allocators are all equal
void swap(RootishArrayStack &o) noexcept(detail::swapNoexcept< A >)
exchanges the blocks with those of o, and the allocators if they propagate on a swap
static std::size_t block(std::size_t i)
the block of the rank , (1)
void insert(std::size_t i, const T &x)
puts at the rank , the items from one rank on, in amortized time
RootishArrayStack & operator=(const RootishArrayStack &o)
the copy assignment, with the allocator of o if it propagates
Definition RootishArrayStack.h:152
T value_type
the type of the items
Definition RootishArrayStack.h:108
const T & const_reference
a constant reference
Definition RootishArrayStack.h:112
T & operator[](std::size_t i)
the item of rank , in the block of (1)
iterator erase(const_iterator first, const_iterator last)
the items of removed, one erase( i ) each; an iterator on the item after them
Definition RootishArrayStack.h:297
RootishArrayStack & operator=(RootishArrayStack &&o)
the move assignment: the memory of o if its allocator propagates or is equal, else its items moved on...
Definition RootishArrayStack.h:160
void push_back(T &&x)
at the end, moved
Definition RootishArrayStack.h:308
RootishArrayStack(const RootishArrayStack &o)
a copy of o, on the allocator that select_on_container_copy_construction() gives
std::ptrdiff_t difference_type
the type of the distances
Definition RootishArrayStack.h:110
allocator_type get_allocator(void) const
the allocator of the blocks
Definition RootishArrayStack.h:120
void erase(std::size_t i)
removes the item of rank , those after it one rank back, in amortized time
std::size_t blocks(void) const
the number of blocks
Definition RootishArrayStack.h:186
T & reference
a reference to an item
Definition RootishArrayStack.h:111
std::size_t capacity(void) const
the places of the blocks,
Definition RootishArrayStack.h:181
const T & front(void) const
the first item
RankIterator< RootishArrayStack, T, false > iterator
the iterator on the items
Definition RootishArrayStack.h:114
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 RootishArrayStack.h:273
RootishArrayStack(RootishArrayStack &&o) noexcept
the blocks of o, which is left empty