An open API service indexing awesome lists of open source software.

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

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';
}
```