summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlberto Sartori <alberto.sartori@huawei.com>2022-06-28 19:12:55 +0200
committerAlberto Sartori <alberto.sartori@huawei.com>2022-06-28 19:12:55 +0200
commitdbc4eca7e08674a1158e48f40c7731cc7b501557 (patch)
tree916d87f3f35f87f85ce15fd2e2566f5dca110ee2 /src
parent0ecb86e63af6e747a7ec812962de00b2179a2cd9 (diff)
downloadjustbuild-dbc4eca7e08674a1158e48f40c7731cc7b501557.tar.gz
define new header-only library for vector manipulation
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