-
Notifications
You must be signed in to change notification settings - Fork 0
awmiller/a4nodequeue
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
CSC 340 Assignment 4 Implementation of Node: Node is a simple data container that allows single linkage. class Node { public: Node(int value); Node *next; int value; }; All members are public because the class is not intended for use outside the this library. Queue is implemented as a singly linked list, the Node's "next" member allows the elements of Queue to "link" to eachother. void Queue::enqueue(int value){ if(this->isEmpty()){ beginning = new Node(value); end = beginning; } else { end->next = new Node(value); end = end->next; } count ++; } int Queue::dequeue(void){ if( this->isEmpty() ) { return EMPTY_VALUE; } int ret = beginning->value; Node *toBeDestroyed = beginning; beginning = beginning->next; delete(toBeDestroyed); count --; return ret; } output: Creating QueueTest --- Testing queue is not empty --- PASS --- Testing queue size is 30 --- PASS --- Testing queue front is 6203 --- PASS --- Testing queue size is 30 --- PASS --- Testing dequeue should be 6203 --- PASS --- Testing queue size is 29 --- PASS --- Testing queue front is 812 --- PASS --- Testing clearing the queue (isEmpty and dequeue) --- PASS --- Testing queue is empty --- PASS --- Testing default value returned when dequeue called on empty Queue --- PASS Destroyed QueueTest
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published