This file contains implementation of Stack class.
More...
#include "list.h"
#include <initializer_list>
#include <iostream>
#include <utility>
Go to the source code of this file.
|
| template<typename T> |
| auto | dsa::operator== (const Stack< T > &stack1, const Stack< T > &stack2) -> bool |
| | The relational operator compares two Stack objects.
|
| template<typename T> |
| auto | dsa::operator< (const Stack< T > &stack1, const Stack< T > &stack2) -> bool |
| | The relational operator compares two Stack objects.
|
| template<typename T> |
| auto | dsa::operator<< (std::ostream &out, const Stack< T > &stack) -> std::ostream & |
| | Overloads operator to print all elements of Stack.
|
| template<typename T> |
| auto | dsa::operator!= (const Stack< T > &stack1, const Stack< T > &stack2) -> bool |
| | The relational operator compares two Stack objects.
|
| template<typename T> |
| auto | dsa::operator> (const Stack< T > &stack1, const Stack< T > &stack2) -> bool |
| | The relational operator compares two Stack objects.
|
| template<typename T> |
| auto | dsa::operator<= (const Stack< T > &stack1, const Stack< T > &stack2) -> bool |
| | The relational operator compares two Stack objects.
|
| template<typename T> |
| auto | dsa::operator>= (const Stack< T > &stack1, const Stack< T > &stack2) -> bool |
| | The relational operator compares two Stack objects.
|
This file contains implementation of Stack class.
- Author
- Michal Zygmunt
- Copyright
- Copyright (c) 2025 Michal Zygmunt This project is distributed under the MIT License. See accompanying LICENSE.txt file or obtain copy at https://opensource.org/license/mit
Definition in file stack.h.
◆ operator!=()
template<typename T>
| auto dsa::operator!= |
( |
const Stack< T > & | stack1, |
|
|
const Stack< T > & | stack2 ) -> bool
|
The relational operator compares two Stack objects.
- Template Parameters
-
| T | type of data stored in Stack |
- Parameters
-
| [in] | stack1 | input container |
| [in] | stack2 | input container |
- Return values
-
| true | if containers are not equal |
| false | if containers are equal |
Definition at line 330 of file stack.h.
331 {
333 }
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.
◆ operator<()
template<typename T>
| auto dsa::operator< |
( |
const Stack< T > & | stack1, |
|
|
const Stack< T > & | stack2 ) -> bool |
The relational operator compares two Stack objects.
Forward friend declaration to access internal container comparison operator.
- Template Parameters
-
| T | type of data stored in Stack |
- Parameters
-
| [in] | stack1 | input container |
| [in] | stack2 | input container |
- Return values
-
| true | if the content of stack1 are lexicographically less than the content of stack2 |
| false | otherwise |
Definition at line 346 of file stack.h.
347 {
348 return stack1.container < stack2.container;
349 }
◆ operator<<()
template<typename T>
| auto dsa::operator<< |
( |
std::ostream & | out, |
|
|
const Stack< T > & | stack ) -> std::ostream&
|
Overloads operator to print all elements of Stack.
- Template Parameters
-
| T | type of initializer list elements |
- Parameters
-
| [in,out] | out | reference to output stream |
| [in] | stack | Stack to print |
- Returns
- std::ostream& reference to std::ostream
Definition at line 292 of file stack.h.
293 {
295
296 while (!temp.
empty())
297 {
298 out << temp.
top() <<
' ';
300 }
301
302 return out;
303 }
void pop()
Function removes the top element of Stack.
auto top() -> reference
Function returns pointer to Stack top element.
auto empty() const -> bool
Function checks if container has no elements.
◆ operator<=()
template<typename T>
| auto dsa::operator<= |
( |
const Stack< T > & | stack1, |
|
|
const Stack< T > & | stack2 ) -> bool
|
The relational operator compares two Stack objects.
- Template Parameters
-
| T | type of data stored in Stack |
- Parameters
-
| [in] | stack1 | input container |
| [in] | stack2 | input container |
- Return values
-
| true | if the content of stack1 are lexicographically less or equal than the content of stack2 |
| false | otherwise |
Definition at line 378 of file stack.h.
379 {
381 }
auto operator>(const List< T > &list1, const List< T > &list2) -> bool
The relational operator compares two List objects.
◆ operator==()
template<typename T>
| auto dsa::operator== |
( |
const Stack< T > & | stack1, |
|
|
const Stack< T > & | stack2 ) -> bool |
The relational operator compares two Stack objects.
Forward friend declaration to access internal container comparison operator.
- Template Parameters
-
| T | type of data stored in Stack |
- Parameters
-
| [in] | stack1 | input container |
| [in] | stack2 | input container |
- Return values
-
| true | if containers are equal |
| false | if containers are not equal |
Definition at line 315 of file stack.h.
316 {
317 return stack1.container == stack2.container;
318 }
◆ operator>()
template<typename T>
| auto dsa::operator> |
( |
const Stack< T > & | stack1, |
|
|
const Stack< T > & | stack2 ) -> bool
|
The relational operator compares two Stack objects.
- Template Parameters
-
| T | type of data stored in Stack |
- Parameters
-
| [in] | stack1 | input container |
| [in] | stack2 | input container |
- Return values
-
| true | if the content of stack1 are lexicographically greater than the content of stack2 |
| false | otherwise |
Definition at line 362 of file stack.h.
363 {
365 }
auto operator<(const List< T > &list1, const List< T > &list2) -> bool
The relational operator compares two List objects.
◆ operator>=()
template<typename T>
| auto dsa::operator>= |
( |
const Stack< T > & | stack1, |
|
|
const Stack< T > & | stack2 ) -> bool
|
The relational operator compares two Stack objects.
- Template Parameters
-
| T | type of data stored in Stack |
- Parameters
-
| [in] | stack1 | input container |
| [in] | stack2 | input container |
- Return values
-
| true | if the content of s1 are lexicographically greater or equal than the content of s2 |
| false | otherwise |
Definition at line 394 of file stack.h.