mirror of
https://github.com/13hannes11/UU_la_parallel_programming_practical_assignments.git
synced 2024-09-04 00:50:58 +02:00
remove unecessary code from stack and readd printing to Treiber stack
This commit is contained in:
@@ -5,8 +5,6 @@
|
|||||||
#include<sstream>
|
#include<sstream>
|
||||||
|
|
||||||
Stack::Stack(ADTOperationQueue * queue){
|
Stack::Stack(ADTOperationQueue * queue){
|
||||||
first = Node::Dummy();
|
|
||||||
first->next = Node::Dummy();
|
|
||||||
op_queue = queue;
|
op_queue = queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,12 +12,4 @@ void Stack::push(int element) { return; }
|
|||||||
int Stack::pop() { return 0; }
|
int Stack::pop() { return 0; }
|
||||||
int Stack::size() { return 0; }
|
int Stack::size() { return 0; }
|
||||||
|
|
||||||
std::string Stack::print_stack(){
|
std::string Stack::print_stack(){ return ""; }
|
||||||
Node* c = this->first->next;
|
|
||||||
std::stringstream ss;
|
|
||||||
while (!c->is_dummy()) {
|
|
||||||
ss << c->get_data() << " ";
|
|
||||||
c = c->next;
|
|
||||||
}
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ class Stack {
|
|||||||
protected:
|
protected:
|
||||||
ADTOperationQueue * op_queue;
|
ADTOperationQueue * op_queue;
|
||||||
Stack(ADTOperationQueue * queue);
|
Stack(ADTOperationQueue * queue);
|
||||||
Node* first;
|
|
||||||
public:
|
public:
|
||||||
void push(int element);
|
void push(int element);
|
||||||
int pop();
|
int pop();
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include<stdexcept>
|
#include<stdexcept>
|
||||||
|
#include<sstream>
|
||||||
|
|
||||||
#include "TreiberStack.h"
|
#include "TreiberStack.h"
|
||||||
#include "ADT_Stack.h"
|
#include "ADT_Stack.h"
|
||||||
@@ -44,3 +45,14 @@ int TreiberStack::size() {
|
|||||||
op_queue->enqueue(create_operation(methodname::size, c));
|
op_queue->enqueue(create_operation(methodname::size, c));
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string TreiberStack::print_stack(){
|
||||||
|
Node* c = this->top;
|
||||||
|
std::stringstream ss;
|
||||||
|
while (c != NULL) {
|
||||||
|
ss << c->get_data() << " ";
|
||||||
|
c = c->next;
|
||||||
|
}
|
||||||
|
std::string s = ss.str();
|
||||||
|
return s.substr(0, s.find_last_not_of(" ") + 1 );
|
||||||
|
}
|
||||||
@@ -12,4 +12,5 @@ class TreiberStack:public Stack{
|
|||||||
void push(int element);
|
void push(int element);
|
||||||
int pop();
|
int pop();
|
||||||
int size();
|
int size();
|
||||||
|
std::string print_stack();
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user