nss: upgrade to release 3.73
[LibreOffice.git] / include / o3tl / vector_utils.hxx
blobdc6d80a9ffbc86c24126d77a9bda49e49601415b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
11 #pragma once
13 #include <vector>
15 namespace o3tl
17 // removes duplicated elements in a vector
18 template <typename T> void remove_duplicates(std::vector<T>& rVector)
20 std::unordered_set<T> aSet;
21 auto aEnd = std::copy_if(rVector.begin(), rVector.end(), rVector.begin(),
22 [&aSet](T const& rElement) { return aSet.insert(rElement).second; });
23 rVector.erase(aEnd, rVector.end());
27 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */