All Projects → spacehuhn → SimpleList

spacehuhn / SimpleList

Licence: MIT license
A simple linked list for Arduino projects

Programming Languages

C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to SimpleList

SSCTaglistView
Customizable iOS tag list view, in Swift.
Stars: ✭ 54 (+25.58%)
Mutual labels:  simple
dice-simulator
A Python simple Dice Simulator just for fun
Stars: ✭ 17 (-60.47%)
Mutual labels:  simple
xml.nim
Simple XML parser in pure Nim
Stars: ✭ 16 (-62.79%)
Mutual labels:  simple
finddups
Find duplicate files on your computer
Stars: ✭ 22 (-48.84%)
Mutual labels:  simple
Simple-Game-ERC-721-Token-Template
🔮 Very Simple ERC-721 Smart Contract Template to create your own ERC-721 Tokens on the Ethereum Blockchain, with many customizable Options 🔮
Stars: ✭ 83 (+93.02%)
Mutual labels:  simple
Simple-Slack-Bot
Simple Python library for creating Slack bots.
Stars: ✭ 26 (-39.53%)
Mutual labels:  simple
Customizable-Crypto-Currency-Dashboard-with-Chart
📺 A Dashboard with the price movements of the selected Cryptocurrencies 💹
Stars: ✭ 79 (+83.72%)
Mutual labels:  simple
mohusman360.github.io
Simple Resume Template with Tailwind CSS
Stars: ✭ 38 (-11.63%)
Mutual labels:  simple
Hacktoberfest-Banned-The-Repo-Guys-Sorry-For-Your-Time-and-effort
A beginner-friendly open source repository to create your first pull request.
Stars: ✭ 27 (-37.21%)
Mutual labels:  simple
Artal
A .PSD parsing library for LÖVE
Stars: ✭ 41 (-4.65%)
Mutual labels:  simple
DLL-INJECTOR
I created a dll injector I am going to Open source its Code. But remember one thing that is any one can use it only for Educational purpose .I again say do not use it to damage anyone's Computer.But one thing if you are using it for some good purpose like to help someone who really need help then I permit you to use it.
Stars: ✭ 14 (-67.44%)
Mutual labels:  simple
nstate
A simple but powerful react state management library with low mind burden
Stars: ✭ 11 (-74.42%)
Mutual labels:  simple
QArchive
Async C++ Cross-Platform library that modernizes libarchive using Qt5 🚀. Simply extracts 7z 🍔, Tarballs 🎱 and other supported formats by libarchive. ❤️
Stars: ✭ 66 (+53.49%)
Mutual labels:  simple
onion-pi
Configures your Raspberry Pi as portable WiFi-WiFi Tor proxy.
Stars: ✭ 13 (-69.77%)
Mutual labels:  simple
base64.c
Base64 Library in C
Stars: ✭ 60 (+39.53%)
Mutual labels:  simple
minstyle.io
👌 A simple CSS Framework, including dark mode.
Stars: ✭ 58 (+34.88%)
Mutual labels:  simple
llb
Dead simple event-driven load-balancer
Stars: ✭ 27 (-37.21%)
Mutual labels:  simple
youtube-lite
No more wasting time on watching random, irrelevant videos on Youtube. https://youtube-lite.js.org
Stars: ✭ 22 (-48.84%)
Mutual labels:  simple
simplenetes
The sns tool is used to manage the full life cycle of your Simplenetes clusters. It integrates with the Simplenetes Podcompiler project podc to compile pods.
Stars: ✭ 731 (+1600%)
Mutual labels:  simple
VPAutoComplete
A simple Auto Complete UITextField also support UITableView written in swift 4.2
Stars: ✭ 20 (-53.49%)
Mutual labels:  simple

SimpleList

Use std::list whenever possible, or at least LinkedList, as it's more tested and still maintained!!!

Nothing big, just my own implementation of a linked list in c++ for all kind of Arduino projects.
This Arduino Library was inspired by the LinkedList and is mostly compatible too it.
I made it to get a deeper understanding of lists.

Installation

  1. Download the source code from GitHub.
  2. Unzip and rename the Folder name to "SimpleList".
  3. Paste it in your Library folder (Usually located somewhere at documents/Arduino/libraries).
  4. Restart the Arduino IDE.

You can also just download the SimpleList.h file and paste it in your Arduino sketch folder.

Usage

Include the library

#include <SimpleList.h>  

Creating a SimpleList

// A list of integer
SimpleList<int> *myLinkedList = new SimpleList<int>();

// A list of 'MyClass'
SimpleList<MyClass> *mySimpleList = new SimpleList<MyClass>();

Getting the list size

int theSize = myList->size();

Adding compare function

// Add a compare function to sort or search the list
    list->setCompare([](int &a, int &b) -> int {
      if(a < b) return -1;
      if(a == b) return 0;
      if(a > b) return 1;  
    });

Adding elements

// add(obj) will add the object at the end of the list
myList->add(myObject);

// add(index, obj) method will insert the object at the specified index
myList->add(0, myObject); // Add at the beginning
myList->add(3, myObject); // Add at index 3

// insert will try to put the object at the correct spot to keep the list isSorted (compare function is required!)
myList->insert(myObject);

Getting elements

// Get the first element
myObject = myList->get(0);

// Get the third element
myObject = myList->get(2);

// Get the last element
myObject = myList->get(myList->size() - 1);

Sorting the list

// PLEASE NOTE: compare function must be set!

// Sort the list
list->sort();

// Check if list is currently sorted
bool isSorted = list->isSorted();

Replacing elements

// Replace the first element
myList->replace(0, myObject);

// Replace the third element
myList->replace(2, myObject);

// Replace the last element
myList->replace(myList->size() - 1, myObject);

Removing elements

// Remove the first object
myList->remove(0);

// pop() will remove and return the last element
myDeletedObject = myList->pop();

// shift() will remove and return the first element
myDeletedObject = myList->shift();

// clear() will erase the entire list, leaving it with 0 elements
myList->clear();

// Please note that clear() wont free memory from pointers, you have to manually delete/free those!
// Example:
while(list->size() > 0){
	delete myList->get(0).somePointer;
	list->remove(0);
}

Searching for elements

// PLEASE NOTE: compare function must be set!

// seach() returns the index of the element, not the element itself!
int indexOfSeven = list->search(7);

// When the list is sorted, you can also do a more efficient binary search
// here find the element
int indexOfIntOne = list->binSearch(1);

Counting elements

// PLEASE NOTE: compare function must be set!
int numberOfZeros = myList->count(0);

Swapping elements

// swap(index-X, index-Y)
list->swap(0, list->size()-1);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].