Skip to content

Commit

Permalink
First reworks done for version 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nkaaf committed Oct 25, 2023
1 parent b97837d commit 6dfeb20
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 164 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ https://semver.org/ compliant

* https://docs.arduino.cc/learn/contributions/arduino-writing-style-guide
* https://docs.arduino.cc/learn/contributions/arduino-library-style-guide
* https://arduino.github.io/arduino-cli/0.33/library-specification/
* https://arduino.github.io/arduino-cli/0.33/sketch-specification/
* https://arduino.github.io/arduino-cli/0.34/library-specification/
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ void setup() {

// Get the first element of both lists
Serial.print("The first element of the first list is: ");
Serial.println(mutableList.getValue(0));
Serial.println(mutableList.get(0));
Serial.print("The first element of the second list is: ");
Serial.println(immutableList.getValue(0));
Serial.println(immutableList.get(0));

Serial.println("All three values are logically the same!");
Serial.println();
Expand All @@ -35,9 +35,9 @@ void setup() {

// Get the first element of both lists
Serial.print("The first element of the first list is: ");
Serial.println(mutableList.getValue(0));
Serial.println(mutableList.get(0));
Serial.print("The first element of the second list is: ");
Serial.println(immutableList.getValue(0));
Serial.println(immutableList.gte(0));

Serial.println("You see, that the first element of the first list has the the new value and the first element of the second list has not changed.");
Serial.println("Elements of mutable lists can be manipulate via the same variable; immutable lists cannot!");
Expand Down
9 changes: 3 additions & 6 deletions examples/List/ManageElements/ManageElements.ino
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Create an immutable list
List<int> list;

// TODO: rvalue
void setup() {
Serial.begin(9600);

Expand All @@ -15,18 +16,14 @@ void setup() {

// Get the first element
Serial.print("The value of the first element with the getValue() method is: ");
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!
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!

// Get the first element (alternative)
Serial.print("The value of the first element with the [] operator is: ");
int firstElement = list[0]; // The '[]' Operator is a synonym for the getValue() method.
Serial.println(firstElement);

// Get the first element (alternative)
Serial.print("The value of the first element with the getPointer() method and '*' is: ");
int *firstElementPtr = list.getPointer(0); // Here, have to be the '*' to get the int Value, because otherwise a pointer (memory address) will be returned.
Serial.println(*firstElementPtr);
free(firstElementPtr); // free the pointer because it is an immutable list
// TODO: add getMutableValue for mutable lists

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.");
Serial.println();
Expand Down
Loading

0 comments on commit 6dfeb20

Please sign in to comment.