This is simple generic Link list for Arduino in C++, without need any requirements.
Since this is generic class you can set type of array in initialization. type must be defined in <>
list<int> obj;
- append
- display
- insertStart
- addNewValueAtIndex
- setValueForIndex
- valueForIndex
- deleteFirst
- deleteLast
- deleteValueAtIndex
- length
append method will add new given element to the end of array.
obj.append(23);
See Also: insertStart and addNewValueAtIndex
this method only works on default c++ iostream, If you wants to use it in Arduino you should change it in your way.
adding new element to top of list, You can’t use it while the list is empty.
obj.insertStart(50);
See Also: append to add first element.
inserting new element to the specific position, the position must be zero index.
obj.addNewValueAtIndex(5, 60); // adding 60 into the positon of 5
See Also: setValueForIndex
changing value of element at specific position, the position must be zero index.
obj.setValueForIndex(5, 60); // changeing value of element at index 5 to 60
See Also: addNewValueAtIndex
Returning value of element at specific position, the position must be zero index.
int foo;
foo = obj.valueForIndex(3);
See Also: setValueForIndex
Deleting top of list element
obj.deleteFirst();
See Also: deleteLast and deleteValueAtIndex
Deleting end of list element
obj.deleteLast();
See Also: deleteFirst and deleteValueAtIndex
Deleting element at specific position, position must be zero index.
obj.deleteValueAtIndex(4);
See Also: deleteLast and deleteFirst
Return number of element exist in the list.
int numberOfElements;
numberOfElements = obj.length();