初始化提交
This commit is contained in:
29
arduino-cli/libraries/QList-master/.gitignore
vendored
Normal file
29
arduino-cli/libraries/QList-master/.gitignore
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
23
arduino-cli/libraries/QList-master/.travis.yml
Normal file
23
arduino-cli/libraries/QList-master/.travis.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
language: cpp
|
||||
sudo: enabled
|
||||
services:
|
||||
- docker
|
||||
stages:
|
||||
- test
|
||||
jobs:
|
||||
include:
|
||||
stage: test
|
||||
install:
|
||||
- sudo docker pull slocomptech/docker-arduino:latest
|
||||
- sudo docker run -it -d --name buildenv slocomptech/docker-arduino bash
|
||||
- sudo docker ps
|
||||
before_script:
|
||||
- sudo docker exec buildenv git clone -b ${TRAVIS_BRANCH} https://github.com/SloCompTech/QList.git QList
|
||||
- sudo docker exec buildenv bash -c 'echo "arduino:avr:uno" >> arduino_platforms.txt && echo "arduino:avr:mega:cpu=atmega2560" >> arduino_platforms.txt && echo "arduino:avr:nano:cpu=atmega328" >> arduino_platforms.txt && echo "arduino:avr:mini:cpu=atmega328" >> arduino_platforms.txt && echo "arduino:avr:micro" >> arduino_platforms.txt'
|
||||
script:
|
||||
- sudo docker exec buildenv bash -c 'arduino_build_lib QList'
|
||||
after_script:
|
||||
- sudo docker stop buildenv
|
||||
- sudo docker rm buildenv
|
||||
- sudo docker rmi slocomptech/docker-arduino:latest
|
||||
- sudo docker ps -a
|
||||
21
arduino-cli/libraries/QList-master/LICENSE
Normal file
21
arduino-cli/libraries/QList-master/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2016 Martin Dagarin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
81
arduino-cli/libraries/QList-master/README.md
Normal file
81
arduino-cli/libraries/QList-master/README.md
Normal file
@@ -0,0 +1,81 @@
|
||||
<p align="center"><img src="logo.png" alt="QList" height="200px"></p>
|
||||
|
||||
# QList
|
||||
[](https://travis-ci.org/SloCompTech/QList)
|
||||
[]()
|
||||
|
||||
Linked list library for Arduino
|
||||
|
||||
Purpose of this library is to enable programmers to create lists of things
|
||||
|
||||
Before we can start using library, we need to include library to our sketch
|
||||
``` C++
|
||||
#include <QList.h>
|
||||
```
|
||||
|
||||
First, we create simple list object example for ints:
|
||||
``` C++
|
||||
QList<int> list;
|
||||
```
|
||||
|
||||
Then we can add items in list:
|
||||
``` C++
|
||||
list.push_front(item); // Push item at the front of the list
|
||||
list.push_back(item); // Push item at the back of the list
|
||||
```
|
||||
|
||||
Items on the list can be removed:
|
||||
``` C++
|
||||
list.pop_front(); // Remove item at the front of the list
|
||||
list.pop_back(); // Remove item at the back of the list
|
||||
/*
|
||||
Remove item at given position
|
||||
WARNING !
|
||||
Note:
|
||||
- index starts with 0 not 1 so interval is [0,n)
|
||||
- always check if index is in valid range before you try to clear item
|
||||
*/
|
||||
list.clear(index);
|
||||
|
||||
list.clear(); // This removes ALL items from list
|
||||
```
|
||||
Items on the list can accessed:
|
||||
``` C++
|
||||
int val1 = list.front(); // Get item at the front of the list
|
||||
int val2 = list.back(); // Get item at the back of the list
|
||||
/*
|
||||
Get item at given position
|
||||
WARNING !
|
||||
Note:
|
||||
- index starts with 0 not 1 so interval is [0,n)
|
||||
- always check if index is in valid range before you try to get item
|
||||
*/
|
||||
int val3 = list.at(index);
|
||||
int val3 = list.get(index);
|
||||
int val3 = list[index];
|
||||
```
|
||||
|
||||
Values of items that are already in the list, can be changed:
|
||||
``` C++
|
||||
/*
|
||||
WARNING !
|
||||
Note:
|
||||
- always check if index is in valid range before you try to change value of item
|
||||
*/
|
||||
list.at(index) = 3;
|
||||
list[index] = 3; // Same as above
|
||||
```
|
||||
|
||||
Size of list can be accessed with:
|
||||
``` C++
|
||||
int list_size = list.size();
|
||||
int same_list_size = list.length();
|
||||
```
|
||||
|
||||
You can also search for items in list:
|
||||
``` C++
|
||||
int pos = list.indexOf(item);
|
||||
if(pos < 0)
|
||||
Serial.println("Item not found");
|
||||
```
|
||||
Note: If item is not found function returns -1
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
Simple List
|
||||
|
||||
This program shows basic usage of QList
|
||||
|
||||
Created 30th November 2016
|
||||
By SloCompTech
|
||||
|
||||
https://github.com/SloCompTech/QList
|
||||
|
||||
*/
|
||||
#include "QList.h"
|
||||
|
||||
QList<String> myList;
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
myList.push_back("First"); // Add item at the back of the line
|
||||
myList.push_back("Second");
|
||||
myList.push_front("New first"); // Ad item at the front of the line
|
||||
myList.at(1) = "NewSecond"; // Changed value of item in the list
|
||||
myList[0] = "NewNewFirst"; // Changed value of item in the list
|
||||
Serial.println("Items:");
|
||||
// Go through items
|
||||
for(int i=0;i<myList.size();i++)
|
||||
{
|
||||
Serial.println(myList.at(i));
|
||||
}
|
||||
myList.pop_back(); // Remove item at the back of the line
|
||||
Serial.println("Items:");
|
||||
for(int i=0;i<myList.size();i++)
|
||||
{
|
||||
Serial.println(myList.at(i));
|
||||
}
|
||||
myList.clear(); // Clear all items in table
|
||||
}
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
||||
13
arduino-cli/libraries/QList-master/keywords.txt
Normal file
13
arduino-cli/libraries/QList-master/keywords.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
QList KEYWORD1
|
||||
push_front KEYWORD2
|
||||
push_back KEYWORD2
|
||||
pop_front KEYWORD2
|
||||
pop_back KEYWORD2
|
||||
front KEYWORD2
|
||||
back KEYWORD2
|
||||
get KEYWORD2
|
||||
size KEYWORD2
|
||||
clear KEYWORD2
|
||||
at KEYWORD2
|
||||
length KEYWORD2
|
||||
indexOf KEYWORD2
|
||||
10
arduino-cli/libraries/QList-master/library.properties
Normal file
10
arduino-cli/libraries/QList-master/library.properties
Normal file
@@ -0,0 +1,10 @@
|
||||
name=QList
|
||||
version=0.6.7
|
||||
author=Martin Dagarin
|
||||
maintainer=Martin Dagarin <SloCompTech@gmail.com>
|
||||
sentence=Library implements linked lists
|
||||
paragraph=It enables to create list of items in order like queue or stack or vector
|
||||
category=Data Processing
|
||||
url=https://github.com/SloCompTech/QList
|
||||
architectures=*
|
||||
includes=QList.h
|
||||
BIN
arduino-cli/libraries/QList-master/logo.png
Normal file
BIN
arduino-cli/libraries/QList-master/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
287
arduino-cli/libraries/QList-master/src/QList.h
Normal file
287
arduino-cli/libraries/QList-master/src/QList.h
Normal file
@@ -0,0 +1,287 @@
|
||||
#ifndef LIB_SCP_QLIST
|
||||
#define LIB_SCP_QLIST
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
class QList
|
||||
{
|
||||
private:
|
||||
typedef struct node
|
||||
{
|
||||
T item;
|
||||
node *next,*prev;
|
||||
}node;
|
||||
|
||||
int len; // Size of list
|
||||
node *start,*end; // Pointers to start and end
|
||||
|
||||
public:
|
||||
QList(); // Class constructor
|
||||
~QList(); // Class destructor
|
||||
|
||||
void push_back(const T i); // Push item at the back of list
|
||||
void push_front(const T i);// Push item at the front of the list
|
||||
void pop_back(); // Pops item from back
|
||||
void pop_front(); // Pops item from front
|
||||
T front(); // get item from front
|
||||
T back(); // get item from back
|
||||
int size(); // Returns size of list
|
||||
void clear(); // Clears list
|
||||
void clear(unsigned int index); // Clears list
|
||||
T get(unsigned int index); // Get item at given index
|
||||
T& at(unsigned int index); // Get item at given index
|
||||
|
||||
// Array operator
|
||||
T& operator[](unsigned int index);
|
||||
const T& operator[](unsigned int index) const; // Not realy needed
|
||||
|
||||
// Non - critical functions
|
||||
int length();
|
||||
int indexOf(T val);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Constructor
|
||||
template<class T>
|
||||
QList<T>::QList()
|
||||
{
|
||||
len = 0;
|
||||
start = NULL;
|
||||
end = NULL;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
template<class T>
|
||||
QList<T>::~QList()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
// Push at front
|
||||
template<class T>
|
||||
void QList<T>::push_front(const T i)
|
||||
{
|
||||
node *tmp = new node;
|
||||
tmp->item = i;
|
||||
tmp->next = NULL;
|
||||
tmp->prev = NULL;
|
||||
|
||||
if(start==NULL) // If list is empty
|
||||
{
|
||||
start = tmp;
|
||||
end = tmp;
|
||||
}
|
||||
else // Insert at start
|
||||
{
|
||||
tmp->next = start;
|
||||
start->prev = tmp;
|
||||
start = tmp;
|
||||
}
|
||||
len++; // Increase size counter
|
||||
}
|
||||
|
||||
// Push at back
|
||||
template<class T>
|
||||
void QList<T>::push_back(const T i)
|
||||
{
|
||||
node *tmp = new node;
|
||||
tmp->item = i;
|
||||
tmp->next = NULL;
|
||||
tmp->prev = NULL;
|
||||
|
||||
if(end==NULL) // If list is empty
|
||||
{
|
||||
start = tmp;
|
||||
end = tmp;
|
||||
}
|
||||
else // Insert at the end
|
||||
{
|
||||
tmp->prev = end;
|
||||
end->next = tmp;
|
||||
end = tmp;
|
||||
}
|
||||
len++; // Increase size counter
|
||||
}
|
||||
|
||||
// Pop from front
|
||||
template<class T>
|
||||
void QList<T>::pop_front()
|
||||
{
|
||||
if(start!=NULL)
|
||||
{
|
||||
node *tmp = start;
|
||||
start = start->next;
|
||||
if(start!=NULL) // Re-link next item to NULL
|
||||
start->prev = NULL;
|
||||
else // List became empty so we need to clear end
|
||||
end = NULL;
|
||||
delete tmp;
|
||||
len--; // Decrease counter
|
||||
}
|
||||
}
|
||||
|
||||
// Pop from back
|
||||
template<class T>
|
||||
void QList<T>::pop_back()
|
||||
{
|
||||
if(end!=NULL)
|
||||
{
|
||||
node *tmp = end;
|
||||
end = end->prev;
|
||||
if(end!=NULL) //Re-link previous item to NULL
|
||||
end->next = NULL;
|
||||
else // List became empty so we need to clear start
|
||||
start = NULL;
|
||||
delete tmp;
|
||||
len--; // Decrease counter
|
||||
}
|
||||
}
|
||||
|
||||
// Get item from front
|
||||
template<class T>
|
||||
T QList<T>::front()
|
||||
{
|
||||
if(start!=NULL)
|
||||
return start->item;
|
||||
//TODO: Catch error when list is empty
|
||||
}
|
||||
|
||||
//Get item from back
|
||||
template<class T>
|
||||
T QList<T>::back()
|
||||
{
|
||||
if(end!=NULL)
|
||||
return end->item;
|
||||
//TODO: Catch error when list is empty
|
||||
}
|
||||
|
||||
// Get size
|
||||
template<class T>
|
||||
int QList<T>::size()
|
||||
{
|
||||
return this->len;
|
||||
}
|
||||
|
||||
// Clear list
|
||||
template<class T>
|
||||
void QList<T>::clear()
|
||||
{
|
||||
node *tmp = start;
|
||||
while(start!=NULL)
|
||||
{
|
||||
tmp = start;
|
||||
start = start->next;
|
||||
delete tmp; // Delete item
|
||||
len--; // Decrease counter
|
||||
}
|
||||
end = NULL;
|
||||
}
|
||||
template<class T>
|
||||
void QList<T>::clear(unsigned int index)
|
||||
{
|
||||
node *tmp = start;
|
||||
for(int i=0;i<=index&&tmp!=NULL;i++)
|
||||
{
|
||||
if(i==index)
|
||||
{
|
||||
if(tmp->prev!=NULL)
|
||||
tmp->prev->next = tmp->next;
|
||||
else
|
||||
start = tmp->next;
|
||||
|
||||
if(tmp->next!=NULL)
|
||||
tmp->next->prev = tmp->prev;
|
||||
else
|
||||
end = tmp->prev;
|
||||
|
||||
len--; // Decrease counter
|
||||
delete tmp; // Delete item
|
||||
break;
|
||||
}
|
||||
else
|
||||
tmp=tmp->next;
|
||||
}
|
||||
}
|
||||
|
||||
// Get at index
|
||||
template<class T>
|
||||
T QList<T>::get(unsigned int index)
|
||||
{
|
||||
node *tmp = start;
|
||||
for(int i=0;i<=index&&tmp!=NULL;i++)
|
||||
{
|
||||
if(i==index)
|
||||
return tmp->item;
|
||||
else
|
||||
tmp=tmp->next;
|
||||
}
|
||||
//TODO: Catch error when index is out of range
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T& QList<T>::at(unsigned int index)
|
||||
{
|
||||
node *tmp = start;
|
||||
for(int i=0;i<=index&&tmp!=NULL;i++)
|
||||
{
|
||||
if(i==index)
|
||||
return tmp->item;
|
||||
else
|
||||
tmp=tmp->next;
|
||||
}
|
||||
//TODO: Catch error when index is out of range
|
||||
}
|
||||
|
||||
// Get length
|
||||
template<class T>
|
||||
int QList<T>::length()
|
||||
{
|
||||
return this->len;
|
||||
}
|
||||
|
||||
// Get index of value
|
||||
template<class T>
|
||||
int QList<T>::indexOf(T val)
|
||||
{
|
||||
for(int i=0;i<this->size();i++)
|
||||
if(this->at(i) == val)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Array operators
|
||||
template<class T>
|
||||
T& QList<T>::operator[](unsigned int index)
|
||||
{
|
||||
node *tmp = start;
|
||||
for(int i=0;i<=index&&tmp!=NULL;i++)
|
||||
{
|
||||
if(i==index)
|
||||
return tmp->item;
|
||||
else
|
||||
tmp=tmp->next;
|
||||
}
|
||||
//TODO: Catch error when index is out of range
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
const T& QList<T>::operator[](unsigned int index) const
|
||||
{
|
||||
node *tmp = start;
|
||||
for(int i=0;i<=index&&tmp!=NULL;i++)
|
||||
{
|
||||
if(i==index)
|
||||
return tmp->item;
|
||||
else
|
||||
tmp=tmp->next;
|
||||
}
|
||||
//TODO: Catch error when index is out of range
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user