Skip to content

Commit

Permalink
removing duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
roymacdonald committed Sep 26, 2024
1 parent c254a2c commit a525826
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
4 changes: 3 additions & 1 deletion commandLine/src/addons/ofAddon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,9 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo
getXCFrameworksRecursively(libsPath, xcframeworks, "macos");
getXCFrameworksRecursively(libsPath, xcframeworks, "osx");


removeDuplicates(libFiles);
removeDuplicates(frameworks);
removeDuplicates(xcframeworks);

}else{

Expand Down
26 changes: 26 additions & 0 deletions commandLine/src/utils/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "ofLog.h"
#include "ofSystemUtils.h"
#include "baseProject.h"
#include <unordered_set>
struct LibraryBinary;

std::string execute_popen(const char* cmd);
Expand Down Expand Up @@ -102,6 +103,31 @@ inline bool isInVector(T item, std::vector<T> & vec){
return bIsInVector;
}


inline void removeDuplicates(std::vector<std::string> & vec){
std::unordered_set<std::string> seen;
std::vector<std::string> output;

for (const auto& value : vec) {
if (seen.insert(value).second) { // If insertion is successful (element not seen before)
output.push_back(value);
}
}
vec = std::move(output);
}

inline void removeDuplicates(std::vector<fs::path> & vec){
std::unordered_set<std::string> seen;
std::vector<fs::path> output;

for (const auto& value : vec) {
if (seen.insert(value.string()).second) { // If insertion is successful (element not seen before)
output.emplace_back(value);
}
}
vec = std::move(output);
}

string colorText(const string & s, int color = 32);
void alert(string msg, int color=32);

Expand Down

0 comments on commit a525826

Please sign in to comment.