Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SOFT253_Template_Weather_OS_54 by
Diff: LinkedList.cpp
- Revision:
- 43:3983059e0d91
- Parent:
- 42:b1f29874ab70
- Child:
- 44:b523c9a9dd97
diff -r b1f29874ab70 -r 3983059e0d91 LinkedList.cpp
--- a/LinkedList.cpp Wed Apr 05 16:12:42 2017 +0000
+++ b/LinkedList.cpp Thu Apr 06 10:48:12 2017 +0000
@@ -55,9 +55,45 @@
void LinkedList::ListAll()
{
Node *n = head;
+ int i = 0;
while(n->next != NULL)
{
- printf("T: %f | H: %f | P: %f |\r\n",n->measure.temperature, n->measure.humidity, n->measure.pressure);
+ i++;
+ printf("%i. T: %f | H: %f | P: %f |\r\n",i ,n->measure.temperature, n->measure.humidity, n->measure.pressure);
n = n->next;
}
+ }
+ void LinkedList::ListX(int x)
+ {
+ Node *n = head;
+ int i = 0;
+ while(n->next != NULL && i < x)
+ {
+ printf("%i. T: %f | H: %f | P: %f |\r\n",i , n->measure.temperature, n->measure.humidity, n->measure.pressure);
+ i++;
+ n = n->next;
+ }
+ }
+ void LinkedList::DeleteAll()
+ {
+ while(head->next != NULL)
+ {
+ Node *n = head;
+ head = head -> next;
+
+ delete n;
+
+ size = 0;
+ }
+ }
+ void LinkedList::DeleteX(int x)
+ {
+ int i = 0;
+ while(head->next != NULL && i < x)
+ {
+ Node *n = head;
+ head = head->next;
+ delete n;
+ }
+ size -= x;
}
\ No newline at end of file
