Question
Code commented componenets in C++ please! SNode.hpp is defined as follows: #ifndef SNODE_HPP_ #define SNODE_HPP_ #include #include using namespace std; class SNode { friend class
Code commented componenets in C++ please!
SNode.hpp is defined as follows:
#ifndef SNODE_HPP_
#define SNODE_HPP_
#include
#include
using namespace std;
class SNode {
friend class SLL;
friend class WebTopic;
string word; // instead of int data, now the data is a string
int priority; // the priority of a node (1,2, or 3)
SNode *next;
public:
SNode(string w, int p);
~SNode();
void printNode();
};
#endif /* SNODE_HPP_ */
(5 pts) Write the accompanying SNode.cpp
--------------------------------------------------------------------------------------------------------------------------------
SLL.hpp is defined as follows:
#ifndef SLL_HPP_
#define SLL_HPP_
#include "SNode.hpp"
#include
#include
using namespace std;
class SLL {
friend class WebTopic;
SNode *first;
SNode *last;
SNode *p2; //points to the node in the list that is the last node with a priority of 2. If you add another node with a priority of 2 to the list, it will be added after this node
//Note that you still only have one list
int size;
public:
SLL();
~SLL();
void printSLL();
// (4 pts) used for testing purposes not actually needed for this
//lab, but useful
void priorityInsert(string s, int p);
//(8 pts)
//This method creates a new node with s as the word and p as the priority and,
//if the priority is 1, adds the new node to the beginning of the list, if it
//is 3, adds the node to the end of the list, and if its 2, it will insert it
//into the list right after pointer p2 (which is the last node with a priority
//of 2. In essence, all the nodes with a priority of 1 are at the beginning
//of the list, all the nodes with a priority of 2 are in the middle of the
//list, and all the nodes with a priority of 3 are at the end of the list.
void push(string s, int p);
// (4 pts)
// pushes a new node (with priority p and word s) onto the end of the stack
// (remember to reset the last pointer) I called this from the
// priorityInsert method.
void addAtFront(string s, int p);
// (5 pts)
// adds a new node (made from word s and priority p) to the beginning of the
// list (remember to reset the first pointer) I called this from
// priorityInsert
void addFirst(string s, int p);
//(4 pts)
//adds the very first node (made from word s and priority p) to an empty list
// I called this from priorityInsert
void addAtP2(string s, int p);
// (6 pts)
// inserts a new node into the middle of the list right after the priority2 p2
// pointer I called this from priorityInsert
int removeAll(string w);
// (10 pts)
// removes all occurrences of word w from the linked list
// this is used to remove every word in the array of stop words from the
// linked list - I returned the number of times the word w was removed from // the list.
string pop();
// 4 pts)
// removes the last node from the linked list, and returns the word from the
// node removed. I called this from removeAll
};
#endif /* SLL_HPP_ */
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started