mirror of
https://github.com/13hannes11/UU_la_parallel_programming_practical_assignments.git
synced 2024-09-04 00:50:58 +02:00
update filenames
This commit is contained in:
5
Assignment_3/lib/ADT_Stack.cpp
Normal file
5
Assignment_3/lib/ADT_Stack.cpp
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
class Stack {
|
||||||
|
void push(int element, bool output);
|
||||||
|
void pop(int element, bool output);
|
||||||
|
void size(int element, bool output);
|
||||||
|
};
|
||||||
@@ -1 +1 @@
|
|||||||
add_library(sets STATIC Node.h Node.cpp Set.h Set.cpp )
|
add_library(sets STATIC Node.h Node.cpp Stack.h Stack.cpp ADT_Stack.cpp )
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Node.h"
|
|
||||||
|
|
||||||
class Set {
|
|
||||||
protected:
|
|
||||||
std::string name;
|
|
||||||
Set(std::string _name);
|
|
||||||
Node* first;
|
|
||||||
public:
|
|
||||||
bool add(int element);
|
|
||||||
bool rmv(int element);
|
|
||||||
bool ctn(int element);
|
|
||||||
std::string get_name();
|
|
||||||
std::string print_set();
|
|
||||||
};
|
|
||||||
@@ -1,21 +1,19 @@
|
|||||||
#include "Set.h"
|
#include "Stack.h"
|
||||||
#include "Node.h"
|
#include "Node.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include<sstream>
|
#include<sstream>
|
||||||
|
|
||||||
Set::Set(std::string _name){
|
Stack::Stack(std::string _name){
|
||||||
name = _name;
|
|
||||||
first = Node::Dummy();
|
first = Node::Dummy();
|
||||||
first->next = Node::Dummy();
|
first->next = Node::Dummy();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Set::add(int element) { return false; }
|
bool Stack::push(int element) { return false; }
|
||||||
bool Set::rmv(int element) { return false; }
|
bool Stack::pop(int element) { return false; }
|
||||||
bool Set::ctn(int element) { return false; }
|
bool Stack::size(int element) { return false; }
|
||||||
std::string Set::get_name() { return name; }
|
|
||||||
|
|
||||||
std::string Set::print_set(){
|
std::string Stack::print_stack(){
|
||||||
Node* c = this->first->next;
|
Node* c = this->first->next;
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
while (!c->is_dummy()) {
|
while (!c->is_dummy()) {
|
||||||
15
Assignment_3/lib/Stack.h
Normal file
15
Assignment_3/lib/Stack.h
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Node.h"
|
||||||
|
|
||||||
|
class Stack {
|
||||||
|
protected:
|
||||||
|
std::string name;
|
||||||
|
Stack(std::string _name);
|
||||||
|
Node* first;
|
||||||
|
public:
|
||||||
|
bool push(int element);
|
||||||
|
bool pop(int element);
|
||||||
|
bool size(int element);
|
||||||
|
std::string print_stack();
|
||||||
|
};
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <lib/Set.cpp>
|
#include <lib/Stack.cpp>
|
||||||
|
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
@@ -16,22 +16,19 @@ using namespace std::chrono;
|
|||||||
|
|
||||||
#define OP_COUNT 100000
|
#define OP_COUNT 100000
|
||||||
|
|
||||||
enum methodname {add, rmv, ctn, noop};
|
enum methodname {push, pop, size, noop};
|
||||||
typedef struct _operation{
|
typedef struct _operation{
|
||||||
methodname method;
|
methodname method;
|
||||||
int input;
|
int input;
|
||||||
} operation;
|
} operation;
|
||||||
|
|
||||||
void do_operation(operation* op, Set* set) {
|
void do_operation(operation* op, Stack* set) {
|
||||||
switch (op->method) {
|
switch (op->method) {
|
||||||
case methodname::ctn:
|
case methodname::push:
|
||||||
set->ctn(op->input);
|
|
||||||
break;
|
break;
|
||||||
case methodname::add:
|
case methodname::pop:
|
||||||
set->add(op->input);
|
|
||||||
break;
|
break;
|
||||||
case methodname::rmv:
|
case methodname::size:
|
||||||
set->rmv(op->input);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user