add possibility to print a set to a string

This commit is contained in:
2021-01-02 18:39:25 +01:00
parent 297ee216dd
commit e76cc094e5
4 changed files with 29 additions and 5 deletions

View File

@@ -1,6 +1,9 @@
#include "Set.h"
#include "Node.h"
#include <iostream>
#include<sstream>
Set::Set(std::string _name){
name = _name;
first = Node::Dummy();
@@ -11,3 +14,13 @@ bool Set::add(int element) { return false; }
bool Set::rmv(int element) { return false; }
bool Set::ctn(int element) { return false; }
std::string Set::get_name() { return name; }
std::string Set::print_set(){
Node* c = this->first->next;
std::stringstream ss;
while (!c->is_dummy()) {
ss << c->get_data() << " ";
c = c->next;
}
return ss.str();
}