mirror of
https://bitbucket.org/Mattrixwv/my-classes.git
synced 2025-12-06 18:23:57 -05:00
Added functions to create a string from a vector
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include <cinttypes>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <cmath>
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
@@ -619,6 +620,21 @@ std::string toBin(T num){
|
||||
return trimmedString;
|
||||
}
|
||||
|
||||
//Print a vector
|
||||
template <class T>
|
||||
std::string printVector(std::vector<T>& ary){
|
||||
std::stringstream str;
|
||||
str << "[";
|
||||
for(int cnt = 0;cnt < ary.size();++cnt){
|
||||
str << ary[cnt];
|
||||
if(cnt < ary.size() - 1){
|
||||
str << ", ";
|
||||
}
|
||||
}
|
||||
str << "]";
|
||||
return str.str();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user