I can't get it to compile. I've tried so many things. The errors |29|error: expected unqualified-id before '{' token| |266|error: expected '}' at end of input| |266|error: expected unqualified-id at end of input| ||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===| Here is the code` #include <iostream> using namespace std; template <class T> // // ADD STATEMENT BELOW TO DECLARE A CLASS NAMED DynStack. class DynStack { private: // // STATEMENT BELOW TO DECLARE A struct NAMED StackNode. struct StackNode; T value; StackNode *next; { T value; StackNode *next; // Constructor StackNode(T val, StackNode *nextP) { …

Member Avatar
Member Avatar
+0 forum 2

Hello All, I want to write a c++ code to sort a queue with the help of another queue and a non array element. Please help me getting the code.

Member Avatar
Member Avatar
+0 forum 3

|29|error: expected unqualified-id before ‘{’ token| |27|error: new types may not be defined in a return type| |27|note: (perhaps a semicolon is missing after the definition of ‘DynStack<T>::StackNode’)| 46|error: ‘StackNode’ does not name a type| ||In member function ‘DynStack<T>::StackNode DynStack<T>::StackNode(T, DynStack<T>::StackNode*)’:| |40|error: ‘value’ was not declared in this scope| ||In constructor ‘DynStack<T>::DynStack()’:| |51|error: ‘top’ was not declared in this scope| ||In member function ‘void DynStack<T>::push(T)’:| |67|error: ‘top’ was not declared in this scope| |67|error: expected type-specifier before ‘StackNode’| |67|error: expected ‘;’ before ‘StackNode’| ||In member function ‘void DynStack<T>::pop(T&)’:| |74|error: ‘temp’ was not declared in this scope| |77|error: expected ‘;’ before …

Member Avatar
Member Avatar
+0 forum 1

Is there a way to sort a vector with a class that has an int variable? I want to have my vector sorted and printed in console. I want to be able to sort the vectors. Say i create a bunch of vectors here on user input `vector<PCB> Disks2[DiskDevices];` Basically if i choose `vector<PCB> Disks2[1];` itll sort 1 if i choose `vector<PCB> Disks2[2];` itll sort 2 based on the Cylinder in the class. And i have this class class PCB { public: void setPID (int a) { PID = a; } int retrievePID() { return PID; } void setFilename (string …

Member Avatar
Member Avatar
+0 forum 3

Is there a way to mimic creating multiple queues like this but with priority queue? This is what i have but i want to now use a priority queue. queue<PCB> Disks[DiskDevices]; I tried this but it doesnt work. priority_queue<PCB> DisksTest[DiskDevices]; It wont compile? What am i doing wrong?

Member Avatar
Member Avatar
+0 forum 3

// This program uses the a queue template to create a queue of strings. #include <iomanip> #include <iostream> #include <cstdlib> using namespace std; // // TO CREATE A "template" class named "T" template <class T> // // TO CREATE A CLASS NAMED "Dynque" class Dynque { private: struct QueueNode { T value; QueueNode *next; QueueNode(T val, QueueNode *nextp = NULL) { value = val; next = nextp; } }; QueueNode *front; QueueNode *rear; int numItems; public: Dynque(); ~Dynque(); // // FUNCTION PROTOTYPE FOR "engueue" // THE FUNCTION DOES NOT RETURN DATA // THE PARAMETER LIST CONTAINS "T" void enqueue(T); // …

Member Avatar
Member Avatar
+0 forum 2

I need a help in generating ideas to create a program using stack+queue. Real life example of stack+queue is needed. Pleaseeeee?

Member Avatar
Member Avatar
+0 forum 1

I want to create a queue that holds certain information. I want it to hold multiple peices of information like below. Name, Age, Race, Sex. How can i create a queue FIFO. that holds multiple pieces of information like this that i can access or add into? Thanks!

Member Avatar
Member Avatar
+0 forum 7

I am trying to print my queue which has values in it. Right now i have this. for(int i = 1; i<ReadyQueue.size(); i++) { } But i am stuck now because i have no idea how to print a queue without popping it off the front. So now i am stuck. How do I print a queue without emptying it? This is my queue queue<int> ReadyQueue;

Member Avatar
Member Avatar
+0 forum 10

I have a class below class CPU { public: void setPID (int a) { PID = a; } int retrievePID() { return PID; } private: int PID; }; And i am curious if you can create a queue into this class? I am trying to queue in a value into the PID I setup my queue below. queue<CPU> CPUQueue; But im not sure how to queue into the value PID? How does this work i am very confused.

Member Avatar
Member Avatar
+0 forum 3

public: Queue() : front(0), back(0) {} void put(TreeNode *ptn) { ListNode *tmp = new ListNode(ptn, 0); if (back == 0) front = tmp; else back->next = tmp; back = tmp; } TreeNode *get() { assert(front); TreeNode *result = front->ptn; ListNode *tmp = front->next; delete front; front = tmp; if (front == 0) back = 0; return result; } I don't understand what put is supposed to do, because we're putting temp in back as well as the front at the beginning and then we're putting temp in the back and to the node pointed by back.

Member Avatar
Member Avatar
+0 forum 2

Looking to test my library and implementing it so that insert function can assign the index of the rear in th e ring after the items are inserted in ring class CircularQueue: def __init__(self, size): """ ------------------------------------------------------- Initializes an empty queue. Data is stored in a list. ------------------------------------------------------- Postconditions: Initializes an empty queue. ------------------------------------------------------- """ self._values = [None] * size return def is_empty(self): """ ------------------------------------------------------- Determines if the list is empty. Use: b = l.is_empty() ------------------------------------------------------- Postconditions: Returns True if the list is empty, False otherwise. ------------------------------------------------------- """ return len(self._values) == 0 def insert(self, value): """ ------------------------------------------------------- Inserts a copy …

Member Avatar
Member Avatar
+0 forum 3

there is a very frustrating problem with my queue linked list. the functions all work its just that after enqueue, dequeue or display the menu displays along with "Enter choice : Only one of the above can be your choice ". whats wrong? #include <stdio.h> #include <conio.h> #include <ctype.h> #include <stdlib.h> #define TRUE 1 #define FALSE 0 void enqueue (); void dequeue(); void list_node(); struct node { char item_name[30]; char item_code[30]; float item_price; struct node *ptrnext; }; struct node *front, *rear , *thisptr , *newptr; void main () { char ch; front=NULL; do { printf("\n\n [----------Queue Menu----------]"); printf("\nA - Enqueue …

Member Avatar
Member Avatar
+0 forum 2

Hello i implemented this FIFO queue: #include <stdio.h> void enqueue(int *, int); int dequeue(int *); int qempty(void); int head = 0; int tail = 0; int qerror(void); #define N 4 int main(void) { int i = 0; int v[N]; while (i < 10) { enqueue(v, i); i++; } while (!qempty()) printf("%d\n", dequeue(v)); } void enqueue(int *q, int x) { //printf("head=%d\ttail=%d\n", head, tail+1); q[tail] = x; if (tail == N) tail = 0; else tail++; printf("tail=%d\n", tail); //if (head == tail) //fprintf(stderr, "full\n"); } int dequeue(int *q) { int x; //if (head == tail) //fprintf(stderr, "empty\n"); x = q[head]; if (head …

Member Avatar
Member Avatar
+0 forum 4

Hi everyone, I am a C/C++ winapi developer and have to rewrite a "Dialog based" application in java, so that it will execute as an applet in any browser. My java skills are very few, since my knowledge is limited to past college classes. The application is not a large scale one, since it only implements a GUI, with a few screen interactions, which are driven by data from udp network connections. In a windows development model, i would create worker threads wich handle the network communication and feed the gui with data through the window message queue, probably using …

Member Avatar
Member Avatar
+0 forum 6

I am trying to implement a priority queue with an unsorted array and hit a wall when I received a Segmentation fault:11. I used gdb and got the error: Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000 0x00000001000017fa in Item<std::string>::setKey (this=0x0, k=3) at PriorityQueueArray.h:27 27 void setKey(const int k) { key = k; } (gdb) backtrace #0 0x00000001000017fa in Item<std::string>::setKey (this=0x0, k=3) at PriorityQueueArray.h:27 #1 0x0000000100001b58 in PriorityQueueArray<std::string>::insertItem (this=0x7fff5fbffb00, k=3, x=@0x7fff5fbffaf8) at PriorityQueueArray.h:48 #2 0x0000000100001430 in main () at PriorityQueue.cpp:50 My code is: ` // // PriorityQueueArray.h // Assignment5 // // Created by Danielle Crowley …

Member Avatar
Member Avatar
+0 forum 1

Hey everyone, I'm new to the concept of stacks and queues. I think I have the basics, but I have a quick question. If I am wanting to swap an object, say x, for another object, say y, in a stack or a queue, is this possible without introducing an array to store the objects? Am I missing someting fundemental about the ADTs? Thank you!

Member Avatar
Member Avatar
+0 forum 1

ok, im working on an assignment implementing a circular queue (fixed size 15), shared memory, normal producer consumer problem, using three semaphores (one for the queue and one for each process). The objective is to have the producer put the characters from mytest.dat (max 150 chars) into a circular queue, while the consumer pulls them and outputs them to the screen. The exit condition for the consumer is the character `*` (which should not be output). Currently the producer does pull the information, however the consumer outputs blank characters and then hangs. Any pointers (no pun intended) would be greatly …

Member Avatar
Member Avatar
+0 forum 1

Okay so I am having trouble with my depart function. When I output I keep getting 0 for the license plate number and the count for each time a car moves is not right. Any help would be great. Thank you. ____________________________________________ The BASHEMUP Parking Garage contains a single lane that holds up to 7 cars. Cars arrive at the south end of the garage and leave from the north end. If a customer arrives to pick up a car that is not the northernmost, all cars to the north of his car are moved out , his car is …

Member Avatar
+0 forum 0

I see this example frequently and thought I'd give it a shot but I've got something unexpected happening with my Queue. I have multiple threads utilizing my producer class but the output doesn't show that it is being written to by each thread. protected Queue<ProductMessage> prodQueue = new ConcurrentLinkedQueue<>(); @Override public void run() { while (true) { prodQueue.add(new ProductMessage(MP3Util.getRandomProduct(), new Date(), MP3Util.regionLookup(MP3Util.getState()))); System.out.println(Thread.currentThread().getName() + "Queue " + prodQueue.size()); try { Thread.sleep(2000); } catch (InterruptedException ex) { Logger.getLogger(ProductProducer.class.getName()).log(Level.SEVERE, null, ex); } } Thread p1 = new Thread(new ProductProducer()); Thread p2 = new Thread(new ProductProducer()); p1.start(); p2.start(); The output shows: Thread-1Queue 3 …

Member Avatar
Member Avatar
+0 forum 12

Here's what I am trying to do: **1. As long as my generic handler gets HttpRequest, push it into a queue and just return empty response so that the request sender does not wait for the long process. 2. A thread keeps checking if there is anything is the queue. If it finds, do its work and save data into DB.** I have been working on `IHttpAsyncHandler` but it just seems to return a work thread back to thread pool so that it can receive another request and the request sender still needs to wait for a response. Does anyone …

Member Avatar
Member Avatar
+0 forum 3

public void Enqueue(int value){ node end = endList.next; end.next=null; endList.data=value; endList.next=end; endList=end; Here is my code for an Enqueue method but when I run it mylist.Enqueue(12); It gives me an error. Is something wrong with my method or am I testing it incorrectly? Thanks.

Member Avatar
Member Avatar
+0 forum 5

Im having some trouble putting together a linked list implementation of a queue. I'm getting a segmentation fault, which I believe is due to my empty() function because in an attempt to fix my empty() function, I made it determine empty based on (current_size == 0) instead of (front_p == NULL). Based on the test program that I ran enqueue, dequeue, etc all work properly. Even empty() works to check if the queue is empty() at the beginning of the program. But after dequeueing everything, the final check for empty() fails; hence why I decided to make the above changes …

Member Avatar
Member Avatar
+0 forum 1

hi, so i have a question relating to sending data in a sequence. i have a class evenvent that reads the data from a txt file. that class has to send data to 2 comunication line async and sync. data sent to async is for ex: 'new' . data that is sent to sync is 'query' and it gets a result back the data in txt file is in sequence 1,2,3,.... when i sent it to the 2 coommunication line i break the data and put it into 2 queues. one queue is for asyn and the oother is for …

Member Avatar
Member Avatar
+0 forum 10

hi, so got a question regargind sending a handler, i have a class for UpdateClient and it has a queue that holds data. this data sould be sent to ether P1 or P2 which are instances of process. Proxy anoher class has to keep track on who is the promary processor whether it is P1 or P2. in the P1 instance i created an bool value if P1 is the primary it is set to true. how do i get this value from Proxy? howp i explained the question clearly. thanks

Member Avatar
Member Avatar
+0 forum 3

I have a queue class code is given below: struct ListNode { ListNode(int value); int value; ListNode* next; }; ListNode::ListNode(int value): value(value), next(nullptr) {} public class queue { public: queue(); ~queue(); bool Empty() const; int Next() const; void Enqueue(int value); void Dequeue(); void DisplayAll() const; int getP() const; private: // Disable copying to keep the example simple queue(queue const& obj); ListNode* head; ListNode* tail; gcroot<String^> name; // Added this }; queue::queue():head(nullptr), tail(nullptr) {} queue::~queue() { while (head != nullptr) { Dequeue(); } } bool queue::Empty() const { return head == nullptr; } int queue::Next() const { return head->value; } void …

Member Avatar
Member Avatar
+0 forum 5

Combining queue and stack link list? hello so here is my question i ave to connect a link lists together, one who behaves like a stack the other like a queue.the numbers used are 11 22 44 77 33 99 66. so the stack link list looks like this 66 99 33 77 44 22 11 queue link list looks like this 11 22 44 77 33 99 66 what i need to do is combine both, connect the stack to the queue to make a new link list with 14 numbers. new link list should look like this 66 …

Member Avatar
Member Avatar
+0 forum 1

How to display odd and even numbers from a queue link list? hello everyone i really need some help right now on this program. what this program is supposed to do is copy 11 22 44 77 33 99 66 into a linked list that behaves like a queue. the program should display the queue, display the odd numbers, display the even numbers. display queue should look like this 11 22 44 77 33 99 66 display odd numbers should look like this 11 77 33 99 display even numbers should look like this 22 44 66 so far i …

Member Avatar
Member Avatar
+0 forum 3

Hi, I an reading a txt file line by line and putting it in to a Queue<string> q = new Queue<string>(); when i execute the program I get a Argument Exception 'Source array was not long enough. Check srcIndex and length, and the array's lower bounds.' how do i handle it i need to implement the program to that the txt reads and put it into a FIFO queue. how to i do this? appreicate a reply thnks

Member Avatar
Member Avatar
+0 forum 16

so i have 4 list of words. what i want to do is for each list go through it and count the number of occurance the word has in the list and print the first 10. when it comes to saving the word and the number of occurance, how do i do it. because the number of words in each list is different. how do i make an array for a unknow number of words? i need to save the word and the number of count for that waord also... aprreciate a reply

Member Avatar
Member Avatar
+0 forum 15

The End.