From dbc4eca7e08674a1158e48f40c7731cc7b501557 Mon Sep 17 00:00:00 2001 From: Alberto Sartori Date: Tue, 28 Jun 2022 19:12:55 +0200 Subject: define new header-only library for vector manipulation --- src/utils/cpp/vector.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/utils/cpp/vector.hpp (limited to 'src/utils/cpp/vector.hpp') 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 + +// sort the passed vector and remove repeated entries +template +void sort_and_deduplicate(std::vector* 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 -- cgit v1.2.3