You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert

3
+
[](https://registry.platformio.org/libraries/nkaaf/List)
4
+
[](https://www.ardu-badge.com/List)
5
5
6
+
## Intention
6
7
Library to extend the Arduino Ecosystem with different List Implementations.
Copy file name to clipboardExpand all lines: examples/List/ManageElements/ManageElements.ino
+7-10Lines changed: 7 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -3,30 +3,27 @@
3
3
// Create an immutable list
4
4
List<int> list;
5
5
6
+
// TODO: rvalue
6
7
voidsetup() {
7
8
Serial.begin(9600);
8
9
9
10
// Add the first element to the list
10
11
int setup1 = 25;
11
-
list.add(setup1);// add() will always place the element at the end of the list. Its synonym is addLast(). addFirst() will place the element directly at the front of the list.
12
+
list.add(setup1);// add() will always place the element at the end of the list. Its synonym is addLast(). addFirst() will place the element directly at the front of the list.
12
13
Serial.println("Inserted the first element");
13
14
14
15
Serial.println();
15
16
16
17
// Get the first element
17
18
Serial.print("The value of the first element with the getValue() method is: ");
18
-
Serial.println(list.getValue(0));// The most comfortable way to get the first elements value is to call the getValue() method. You cannot get the address of the element with the getValue() method!
19
+
Serial.println(list.get(0));// The most comfortable way to get the first elements value is to call the getValue() method. You cannot get the address of the element with the getValue() method!
19
20
20
21
// Get the first element (alternative)
21
22
Serial.print("The value of the first element with the [] operator is: ");
22
-
int firstElement = list[0];// The '[]' Operator is a synonym for the getValue() method.
23
+
int firstElement = list[0];// The '[]' Operator is a synonym for the getValue() method.
23
24
Serial.println(firstElement);
24
25
25
-
// Get the first element (alternative)
26
-
Serial.print("The value of the first element with the getPointer() method and '*' is: ");
27
-
int *firstElementPtr = list.getPointer(0); // Here, have to be the '*' to get the int Value, because otherwise a pointer (memory address) will be returned.
28
-
Serial.println(*firstElementPtr);
29
-
free(firstElementPtr); // free the pointer because it is an immutable list
26
+
// TODO: add getMutableValue for mutable lists
30
27
31
28
Serial.println("As you can see, there are three possible ways to get the value. The last way is not for beginners because you have to handle pointers.");
32
29
Serial.println();
@@ -45,7 +42,7 @@ void setup() {
45
42
}
46
43
47
44
// Remove element from list
48
-
list.remove(3);// With this, you will remove the third element of the list.
45
+
list.remove(3);// With this, you will remove the third element of the list.
49
46
Serial.print("After the deletion of the third element, the list has: ");
Copy file name to clipboardExpand all lines: library.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
{
2
2
"name": "List",
3
-
"version": "2.1.4",
3
+
"version": "3.0.0",
4
4
"description": "The Ultimate Collection of Lists. This library extends the Arduino ecosystem with the functionality of several easy-to-use lists for numerous purposes.",
0 commit comments