summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/utils/cpp/TARGETS6
-rw-r--r--src/utils/cpp/vector.hpp14
2 files changed, 20 insertions, 0 deletions
diff --git a/src/utils/cpp/TARGETS b/src/utils/cpp/TARGETS
index 7268f10a..a0b23a5b 100644
--- a/src/utils/cpp/TARGETS
+++ b/src/utils/cpp/TARGETS
@@ -43,4 +43,10 @@
, "hdrs": ["path.hpp"]
, "stage": ["src", "utils", "cpp"]
}
+, "vector":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["vector"]
+ , "hdrs": ["vector.hpp"]
+ , "stage": ["src", "utils", "cpp"]
+ }
}
diff --git a/src/utils/cpp/vector.hpp b/src/utils/cpp/vector.hpp
new file mode 100644
index 00000000..e21f49cc
--- /dev/null
+++ b/src/utils/cpp/vector.hpp
@@ -0,0 +1,14 @@
+#ifndef INCLUDED_SRC_UTILS_CPP_VECTOR_HPP
+#define INCLUDED_SRC_UTILS_CPP_VECTOR_HPP
+
+// small library to manipulate vectors
+#include <vector>
+
+// sort the passed vector and remove repeated entries
+template <typename T>
+void sort_and_deduplicate(std::vector<T>* x) {
+ std::sort(x->begin(), x->end());
+ auto it = std::unique(x->begin(), x->end());
+ x->erase(it, x->end());
+}
+#endif \ No newline at end of file