https://github.com/abdullahselek/linkedlistcxx
C++ generic LinkedList implementation.
https://github.com/abdullahselek/linkedlistcxx
cpp generic library linkedlist
Last synced: 15 days ago
JSON representation
C++ generic LinkedList implementation.
- Host: GitHub
- URL: https://github.com/abdullahselek/linkedlistcxx
- Owner: abdullahselek
- License: mit
- Created: 2017-05-21T18:58:52.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-10T08:12:30.000Z (almost 8 years ago)
- Last Synced: 2024-12-26T23:26:33.171Z (5 months ago)
- Topics: cpp, generic, library, linkedlist
- Language: C++
- Homepage:
- Size: 34.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# linkedlistcxx
[](https://travis-ci.org/abdullahselek/linkedlistcxx)
[](https://ci.appveyor.com/project/abdullahselek/linkedlistcxx)LinkedList implementation with C++ as a library.
## Building Repository
To build the repository you need CMake. You can download from [here](https://cmake.org/download/).
You can create a shortcut ```cmake``` command for macOS as below```
sudo mkdir -p /usr/local/bin
sudo /Applications/CMake.app/Contents/bin/cmake-gui --install=/usr/local/bin
```After cloning repository to your own local machine go to project root folder and run
```
cmake .
```and then
```
cmake --build .
```to run unit tests for UNIX machines
```
cd test
./tests --gtest_color=yes
```and for Windows machines
```
cd test/Debug/
tests.exe --gtest_color=yes
```## Sample Usage
Initiate linkedlist as below
```
LinkedList *linkedList = new LinkedList();
```Initiation of Node
```
std::string strNext("next");
std::string strNode("node");Node *next = new Node(strNext, nullptr);
Node *node = new Node(strNode, next);
```Adding first node
```
std::string strFirst("first");
Node *first = new Node(strFirst, nullptr);
linkedList->addFirst(first);
```Getting first node's data
```
std::string data = linkedList->getFirst();
```Removing head from LinkedList
```
std::string headData = linkedList->removeFirst()
```Adding last node
```
std::string strLast("last");
Node *last = new Node(strLast, nullptr);
```Adding data as node
```
std::string last("last");
std::string head("head");
linkedList->add(nullptr, head);
linkedList->add(linkedList->getHead(), last);
```Clear LinkedList
```
linkedList->clear();
```Searching for node data
```
std::string mid("mid");
Node *foundNode = linkedList->searchNode(mid);
```Delete node
```
std::string mid("mid");
Node *node = linkedList->searchNode(mid);
bool isDeleted = linkedList->deleteNode(node);
```