42 template<
class type_t,
class container_t = std::deque<type_t>>
43 class raw_stack final :
public std::stack<type_t, container_t> {
85 template<
class input_iterator_t>
89 template<
class allocator_t>
148 auto clear() ->
void {base_type::c.clear();}
154 base_type::push(value);
155 ensure_capacity(base_type::c.
size());
162 base_type::push(std::move(value));
163 ensure_capacity(base_type::c.
size());
170 ensure_capacity(
size());
177 if (capacity_ >= count)
return;
178 ensure_capacity(count);
184 base_type::c.shrink_to_fit();
185 capacity_ = base_type::c.size();
202 auto original_size = base_type::size();
203 base_type::c.resize(capacity_);
204 base_type::c.resize(original_size);
213 template<
class container_t>
214 raw_stack(container_t) -> raw_stack<typename container_t::value_type, container_t>;
216 template<
class container_t,
class allocator_t>
217 raw_stack(container_t, allocator_t) -> raw_stack<typename container_t::value_type, container_t>;
219 template<
class input_iterator_t>
220 raw_stack(input_iterator_t, input_iterator_t) -> raw_stack<typename std::iterator_traits<input_iterator_t>::value_type>;
222 template<
class input_iterator_t,
class allocator_t>
223 raw_stack(input_iterator_t, input_iterator_t, allocator_t) -> raw_stack<typename std::iterator_traits<input_iterator_t>::value_type, std::deque<typename std::iterator_traits<input_iterator_t>::value_type, allocator_t>>;
auto shrink_to_fit() -> void
Reduces capacity to fit the current size.
Definition raw_stack.hpp:183
raw_stack()
Default constructor. Initializes an empty stack.
Definition raw_stack.hpp:63
auto cend() const -> const_iterator
Gets a const iterator to the end of the stack.
Definition raw_stack.hpp:110
typename base_type::value_type value_type
Type of elements stored.
Definition raw_stack.hpp:50
auto rend() const -> const_reverse_iterator
Gets a const reverse iterator to the end of the stack.
Definition raw_stack.hpp:137
raw_stack(const allocator_t &alloc)
Constructs a stack with a specific allocator.
Definition raw_stack.hpp:90
auto begin() const -> const_iterator
Gets a const iterator to the beginning of the stack.
Definition raw_stack.hpp:98
typename base_type::size_type size_type
Unsigned integer type used for size and capacity.
Definition raw_stack.hpp:51
auto clear() -> void
Removes all elements from the stack.
Definition raw_stack.hpp:148
auto reserve(size_type count) -> void
Reserves storage to hold at least count elements.
Definition raw_stack.hpp:176
typename base_type::container_type container_type
The underlying container type.
Definition raw_stack.hpp:49
auto crbegin() const -> const_reverse_iterator
Gets a const reverse iterator to the beginning of the stack.
Definition raw_stack.hpp:114
auto items() noexcept -> base_type &
Access to the underlying base stack.
Definition raw_stack.hpp:126
auto size() const noexcept -> size_type
Gets the number of elements in the stack.
Definition raw_stack.hpp:141
auto end() const -> const_iterator
Gets a const iterator to the end of the stack.
Definition raw_stack.hpp:122
auto items() const noexcept -> const base_type &
Access to the underlying base stack.
Definition raw_stack.hpp:129
raw_stack(input_iterator_t first, input_iterator_t last)
Constructs a stack from a range of iterators.
Definition raw_stack.hpp:86
auto push(value_type &&value) -> void
Moves the element into the back of the stack.
Definition raw_stack.hpp:161
auto capacity() const noexcept -> size_type
Definition raw_stack.hpp:102
raw_stack(raw_stack &&other)
Move constructor.
Definition raw_stack.hpp:79
typename base_type::const_reference const_reference
Const reference to element type.
Definition raw_stack.hpp:53
typename container_type::const_reverse_iterator const_reverse_iterator
Const reverse iterator type.
Definition raw_stack.hpp:55
raw_stack(const raw_stack &other)
Copy constructor.
Definition raw_stack.hpp:74
std::stack< type_t, container_t > base_type
The base STL stack type.
Definition raw_stack.hpp:48
auto push(const value_type &value) -> void
Adds a copy of the element at the back of the stack.
Definition raw_stack.hpp:153
auto rbegin() const -> const_reverse_iterator
Gets a const reverse iterator to the beginning of the stack.
Definition raw_stack.hpp:133
raw_stack(size_type capacity)
Constructs an empty stack with reserved capacity.
Definition raw_stack.hpp:68
raw_stack & operator=(const raw_stack &other)=default
Copy assignment.
typename base_type::reference reference
Reference to element type.
Definition raw_stack.hpp:52
typename container_type::const_iterator const_iterator
Const iterator type.
Definition raw_stack.hpp:54
auto pop() -> void
Removes the element at the front of the stack.
Definition raw_stack.hpp:168
auto cbegin() const -> const_iterator
Gets a const iterator to the beginning of the stack.
Definition raw_stack.hpp:106
auto crend() const -> const_reverse_iterator
Gets a const reverse iterator to the end of the stack.
Definition raw_stack.hpp:118
raw_stack & operator=(raw_stack &&other)=default
Move assignment.
#define self_
The self_ expression is a reference value expression whose value is the reference of the implicit obj...
Definition self.hpp:20
@ other
The operating system is other.
Definition platform_id.hpp:60
The xtd::collections::generic::helpers namespace contains helpers for generic collections,...
Definition allocator.hpp:14
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.hpp:16
The xtd::collections namespace contains interfaces and classes that define various collections of obj...
Definition any_pair.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
read_only_span< type_t, count > first() const
Obtains a subspan consisting of the first count elements of the sequence.
Definition read_only_span.hpp:282
read_only_span< type_t, count > last() const
Obtains a subspan consisting of the last N elements of the sequence.
Definition read_only_span.hpp:307