https://github.com/agauniyal/smartlist
Unique_ptr based Linked List implementation for reference
https://github.com/agauniyal/smartlist
cpp cpp14 linked-list modern-cpp
Last synced: 12 months ago
JSON representation
Unique_ptr based Linked List implementation for reference
- Host: GitHub
- URL: https://github.com/agauniyal/smartlist
- Owner: agauniyal
- License: mit
- Created: 2017-10-13T16:54:15.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-18T09:10:42.000Z (about 8 years ago)
- Last Synced: 2025-01-28T10:24:00.881Z (over 1 year ago)
- Topics: cpp, cpp14, linked-list, modern-cpp
- Language: C++
- Size: 8.79 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# smartList
Unique_ptr based Linked List implementation for reference
```cpp
#include
#include "include/smartList.hpp"
using std::cout;
const auto print = [](const auto N) { cout << N << ' '; };
int main()
{
SmartList list;
std::cout << std::boolalpha << list.size() << ' ' << list.empty() << '\n';
list.push_back({ 2, 1, 1, 3, 4, 5 });
list.push_back(6);
list.forEach(print);
cout << '\n';
std::cout << std::boolalpha << list.size() << ' ' << list.empty() << '\n';
std::cout << "At index 0: " << list.value_at(0).value() << '\n';
list.remove(1);
list.forEach(print);
cout << '\n';
list.forEach([](auto &num) { num *= 10; });
list.forEach(print);
cout << '\n';
list.reverse();
list.forEach(print);
cout << '\n';
std::cout << "At index 4: " << list.value_at(4).value() << '\n';
}
```