This file contains implementation of List class.
More...
#include <cstddef>
#include <cstdint>
#include <initializer_list>
#include <iostream>
#include <iterator>
#include <limits>
#include <memory>
#include <ranges>
Go to the source code of this file.
|
| template<typename T> |
| auto | dsa::operator+ (const List< T > &list1, const List< T > &list2) -> List< T > |
| | Construct new object based on two List objects.
|
| template<typename T> |
| auto | dsa::operator<< (std::ostream &out, const List< T > &list) -> std::ostream & |
| | Overloads operator to print all elements of List.
|
| template<typename T> |
| auto | dsa::operator== (const List< T > &list1, const List< T > &list2) -> bool |
| | The relational operator compares two List objects.
|
| template<typename T> |
| auto | dsa::operator!= (const List< T > &list1, const List< T > &list2) -> bool |
| | The relational operator compares two List objects.
|
| template<typename T> |
| auto | dsa::operator< (const List< T > &list1, const List< T > &list2) -> bool |
| | The relational operator compares two List objects.
|
| template<typename T> |
| auto | dsa::operator> (const List< T > &list1, const List< T > &list2) -> bool |
| | The relational operator compares two List objects.
|
| template<typename T> |
| auto | dsa::operator<= (const List< T > &list1, const List< T > &list2) -> bool |
| | The relational operator compares two List objects.
|
| template<typename T> |
| auto | dsa::operator>= (const List< T > &list1, const List< T > &list2) -> bool |
| | The relational operator compares two List objects.
|
This file contains implementation of List 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 list.h.
◆ operator!=()
template<typename T>
| auto dsa::operator!= |
( |
const List< T > & | list1, |
|
|
const List< T > & | list2 ) -> bool
|
The relational operator compares two List objects.
- Template Parameters
-
| T | type of data stored in List |
- Parameters
-
| [in] | list1 | input container |
| [in] | list2 | input container |
- Return values
-
| true | if containers are not equal |
| false | if containers are equal |
Definition at line 1928 of file list.h.
1929 {
1931 }
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 List< T > & | list1, |
|
|
const List< T > & | list2 ) -> List< T > |
Construct new object based on two List objects.
- Template Parameters
-
| T | type of data stored in List Node |
- Parameters
-
| [in] | list1 | input List |
| [in] | list2 | input List |
- Returns
- List<T> List<T> with content of two input lists
Definition at line 1846 of file list.h.
1847 {
1849
1850 for (
auto iter = list2.
cbegin(); iter != list2.
cend(); ++iter)
1851 {
1852 T value = *iter;
1853 temp.push_back(value);
1854 }
1855
1856 return temp;
1857 }
Implements List using Node with pointer to adjacent elements as internal base.
auto cend() const -> const_iterator
Function returns pointer to List last Node.
auto cbegin() const -> const_iterator
Function returns const pointer to List first Node.
◆ operator<()
template<typename T>
| auto dsa::operator< |
( |
const List< T > & | list1, |
|
|
const List< T > & | list2 ) -> bool
|
The relational operator compares two List objects.
- Template Parameters
-
| T | type of data stored in List |
- Parameters
-
| [in] | list1 | input container |
| [in] | list2 | input container |
- Return values
-
| true | if the content of list1 are lexicographically less than the content of list2 |
| false | otherwise |
Definition at line 1944 of file list.h.
1945 {
1946 auto list1_iter = list1.
cbegin();
1947 auto list2_iter = list2.
cbegin();
1948
1949 while (list1_iter != list1.
cend() && list2_iter != list2.
cend())
1950 {
1951 if (*list1_iter > *list2_iter)
1952 {
1953 return false;
1954 }
1955 if (*list1_iter < *list2_iter)
1956 {
1957 return true;
1958 }
1959
1960 list1_iter++;
1961 list2_iter++;
1962 }
1963
1964
1965
1966 return list1.
size() < list2.
size();
1967 }
auto size() const -> size_t
Function returns List size.
◆ operator<<()
template<typename T>
| auto dsa::operator<< |
( |
std::ostream & | out, |
|
|
const List< T > & | list ) -> std::ostream&
|
Overloads operator to print all elements of List.
- Template Parameters
-
| T | type of initializer list elements |
- Parameters
-
| [in,out] | out | reference to output stream |
| [in] | list | List to print |
- Returns
- std::ostream&
Definition at line 1868 of file list.h.
1869 {
1871 {
1872 return out;
1873 }
1874
1875 for (
auto iter = list.
cbegin(); iter != list.
cend(); ++iter)
1876 {
1877 T value = *iter;
1878 out << value << ' ';
1879 }
1880
1881 return out;
1882 }
auto empty() const -> bool
Function checks if container has no elements.
◆ operator<=()
template<typename T>
| auto dsa::operator<= |
( |
const List< T > & | list1, |
|
|
const List< T > & | list2 ) -> bool
|
The relational operator compares two List objects.
- Template Parameters
-
| T | type of data stored in List |
- Parameters
-
| [in] | list1 | input container |
| [in] | list2 | input container |
- Return values
-
| true | if the content of list1 are lexicographically less or equal than the content of list2 |
| false | otherwise |
Definition at line 1996 of file list.h.
1997 {
1999 }
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 List< T > & | list1, |
|
|
const List< T > & | list2 ) -> bool
|
The relational operator compares two List objects.
- Template Parameters
-
| T | type of data stored in List |
- Parameters
-
| [in] | list1 | input container |
| [in] | list2 | input container |
- Return values
-
| true | if containers are equal |
| false | if containers are not equal |
Definition at line 1894 of file list.h.
1895 {
1897 {
1898 return false;
1899 }
1900
1901 auto list1_iter = list1.
cbegin();
1902 auto list2_iter = list2.
cbegin();
1903
1904 while (list1_iter != list1.
cend())
1905 {
1906 if (*list1_iter != *list2_iter)
1907 {
1908 return false;
1909 }
1910
1911 list1_iter++;
1912 list2_iter++;
1913 }
1914
1915 return true;
1916 }
◆ operator>()
template<typename T>
| auto dsa::operator> |
( |
const List< T > & | list1, |
|
|
const List< T > & | list2 ) -> bool
|
The relational operator compares two List objects.
- Template Parameters
-
| T | type of data stored in List |
- Parameters
-
| [in] | list1 | input container |
| [in] | list2 | input container |
- Return values
-
| true | if the content of list1 are lexicographically greater than the content of list2 |
| false | otherwise |
Definition at line 1980 of file list.h.
1981 {
1983 }
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 List< T > & | list1, |
|
|
const List< T > & | list2 ) -> bool
|
The relational operator compares two List objects.
- Template Parameters
-
| T | type of data stored in List |
- Parameters
-
| [in] | list1 | input container |
| [in] | list2 | input container |
- Return values
-
| true | if the content of list1 are lexicographically greater or equal than the content of list2 |
| false | otherwise |
Definition at line 2012 of file list.h.