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:
- 42:b1f29874ab70
- Parent:
- 40:ba083993b481
- Child:
- 43:3983059e0d91
--- a/LinkedList.cpp Wed Apr 05 15:40:24 2017 +0000
+++ b/LinkedList.cpp Wed Apr 05 16:12:42 2017 +0000
@@ -3,41 +3,43 @@
#include <ctype.h>
// constructor
LinkedList::LinkedList()
- {
-
+ {
+ size = 0;
head = NULL;
- }
+ }
void LinkedList::addValueFront(Measure _measure){
Node *n = new Node();
n->measure = _measure;
n->next = head;
- head = n;
+ head = n;
+
+ size++;
}
- void LinkedList::addValueEnd(Measure _measure)
+ void LinkedList::addValueEnd(Measure _measure)
+ {
+ if(head == NULL)
{
- if(head == NULL)
- {
- Node *aux = new Node();
- aux->measure = _measure;
- aux->next = NULL;
- head = aux;
- }
- else
+ Node *aux = new Node();
+ aux->measure = _measure;
+ aux->next = NULL;
+ head = aux;
+ }
+ else
+ {
+ Node *n = head;
+ while(n->next != NULL)
{
- Node *n = head;
- while(n->next != NULL)
- {
- n = n->next;
- }
- Node *aux = new Node();
- aux->measure = _measure;
- aux->next = NULL;
- n->next = aux;
+ n = n->next;
+ }
+ Node *aux = new Node();
+ aux->measure = _measure;
+ aux->next = NULL;
+ n->next = aux;
}
+ size++;
}
-
Measure LinkedList::popValueFRONT()
{
Node *n = head;
@@ -45,5 +47,17 @@
head = head->next;
delete n;
+
+ size--;
+
return _measure;
+ }
+ void LinkedList::ListAll()
+ {
+ Node *n = head;
+ while(n->next != NULL)
+ {
+ printf("T: %f | H: %f | P: %f |\r\n",n->measure.temperature, n->measure.humidity, n->measure.pressure);
+ n = n->next;
+ }
}
\ No newline at end of file
