17#include <initializer_list>
79 Stack(
const std::initializer_list<T>& init_list);
138 [[nodiscard]] auto
empty() const ->
bool;
145 [[nodiscard]] auto
size() const ->
size_t;
171 friend auto operator==<T>(const
Stack<T>& stack1, const
Stack<T>& stack2) ->
bool;
176 friend auto operator< <T>(const
Stack<T>& stack1, const
Stack<T>& stack2) ->
bool;
184 for (
const auto& item : init_list)
186 container.push_back(item);
193 if (other.
size() >= 1)
195 for (
const auto& item : other.container)
197 container.push_back(item);
207 while (!container.empty())
209 container.pop_front();
212 for (
const auto& item : other.container)
214 container.push_back(item);
224 std::swap(container, other.container);
232 std::swap(container, other.container);
241 return container.back();
247 return container.back();
253 return container.size() == 0;
259 return container.size();
265 container.push_back(value);
271 container.pop_back();
279 std::swap(container, other.container);
296 while (!temp.
empty())
298 out << temp.
top() <<
' ';
317 return stack1.container == stack2.container;
348 return stack1.container < stack2.container;
constexpr auto operator==(const Array< T, N > &lhs, const Array< T, N > &rhs) noexcept(noexcept(*lhs.begin()== *rhs.begin())) -> bool
The relational operator compares two Array objects.
auto operator<<(std::ostream &out, const Array< T, N > &array) -> std::ostream &
Overloads operator to print all elements of Array.
Implements List using Node with pointer to adjacent elements as internal base.
T & reference
Alias for reference to data type used in class.
T value_type
Alias for data type used in class.
void swap(Stack< T > &other) noexcept
Function swaps content of two Stack objects.
const T & const_reference
Alias for const reference to data type used in class.
void push(T value)
Function add new element at the top of Stack.
~Stack()=default
Destroy the Stack object.
auto operator=(const Stack< T > &other) -> Stack &
Constructs Stack using copy assignment.
friend auto operator<(const Stack< T > &stack1, const Stack< T > &stack2) -> bool
Forward friend declaration to access internal container comparison operator.
void pop()
Function removes the top element of Stack.
auto size() const -> size_t
Function returns Stack size.
Stack()=default
Construct a new Stack object.
friend auto operator==(const Stack< T > &stack1, const Stack< T > &stack2) -> bool
Forward friend declaration to access internal container comparison operator.
auto top() -> reference
Function returns pointer to Stack top element.
auto empty() const -> bool
Function checks if container has no elements.
This file contains implementation of List class.
auto operator>(const List< T > &list1, const List< T > &list2) -> bool
The relational operator compares two List objects.
auto operator>=(const List< T > &list1, const List< T > &list2) -> bool
The relational operator compares two List objects.
auto operator<=(const List< T > &list1, const List< T > &list2) -> bool
The relational operator compares two List objects.
auto operator!=(const List< T > &list1, const List< T > &list2) -> bool
The relational operator compares two List objects.
auto operator<(const List< T > &list1, const List< T > &list2) -> bool
The relational operator compares two List objects.