You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#include "basicFIFO.h"
inline bool basicFIFO::pushData(void * buffer){ if (head == NULL) { head = (pDataPackageFIFO) malloc(sizeof(DataPackageFIFO)); if (head == NULL) { return false; }; head->data = (void *) buffer; head->next = NULL; tale = head; nodeCount = 1; return true; } else { pDataPackageFIFO tNode; tNode = (pDataPackageFIFO) malloc(sizeof(DataPackageFIFO)); if (tNode == NULL) { return false; }; tNode->data = (void *) buffer; tNode->next = NULL; tale->next = tNode; tale = tNode; nodeCount++; return true; };}
bool basicFIFO::pushNode(pDataPackageFIFO & node){ if (head == NULL) { head = node; tale = head; nodeCount = 1; if (tale->next != NULL) { return pushNode(tale->next); } else { return true; } } else { tale->next = node; tale = node; nodeCount++; if (tale->next != NULL) { return pushNode(tale->next); } else { return true; } };}
pDataPackageFIFO basicFIFO::popNode(void){ if (head == NULL) { return NULL; }; pDataPackageFIFO rVal; rVal = head; head = head->next; if (tale == rVal) { tale = head; }; nodeCount--; return rVal;}
void * basicFIFO::popData(void){ if (head == NULL) { return NULL; }; void * rVal; pDataPackageFIFO tVal; rVal = head->data; tVal = head; head = head->next; if (tale == tVal) { tale = head; }; nodeCount--; delete(tVal); return rVal;}
bool basicFIFO::clear(void){ if (head == NULL) { nodeCount = 0; tale = head; return true; };
pDataPackageFIFO tVal; tVal = head; head = head->next;
tVal->next = NULL; removeNode(tVal);
if (head != NULL) { this->clear(); } else { tale = NULL; nodeCount = 0; }; return true;}
pDataPackageFIFO basicFIFO::touch(int index){ if (index < nodeCount) { pDataPackageFIFO rVal; rVal = head; while (index) { rVal = rVal->next; index--; }; return rVal; }; return NULL;}
bool basicFIFO::removeNode(pDataPackageFIFO & node){ if (node->next == NULL) { free(node->data); delete(node); return true; }; return false;}
|