diff options
author | Alberto Sartori <alberto.sartori@huawei.com> | 2022-06-28 19:12:55 +0200 |
---|---|---|
committer | Alberto Sartori <alberto.sartori@huawei.com> | 2022-06-28 19:12:55 +0200 |
commit | dbc4eca7e08674a1158e48f40c7731cc7b501557 (patch) | |
tree | 916d87f3f35f87f85ce15fd2e2566f5dca110ee2 /src/utils/cpp/vector.hpp | |
parent | 0ecb86e63af6e747a7ec812962de00b2179a2cd9 (diff) | |
download | justbuild-dbc4eca7e08674a1158e48f40c7731cc7b501557.tar.gz |
define new header-only library for vector manipulation
Diffstat (limited to 'src/utils/cpp/vector.hpp')
-rw-r--r-- | src/utils/cpp/vector.hpp | 14 |
1 files changed, 14 insertions, 0 deletions
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 |