rsl 1.1.0
ROS Support Library
Loading...
Searching...
No Matches
algorithm.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <algorithm>
4
5namespace rsl {
6
18template <typename Collection>
19[[nodiscard]] auto contains(Collection const& collection,
20 typename Collection::const_reference value) {
21 return std::find(collection.cbegin(), collection.cend(), value) != collection.cend();
22}
23
36template <typename Collection>
37[[nodiscard]] auto is_unique(Collection collection) {
38 std::sort(collection.begin(), collection.end());
39 return std::adjacent_find(collection.cbegin(), collection.cend()) == collection.cend();
40}
41
42} // namespace rsl
auto contains(Collection const &collection, typename Collection::const_reference value)
Determine if a collection contains a value. Example usage:
Definition algorithm.hpp:19
auto is_unique(Collection collection)
Determine if all elements in a collection are unique. Example usage:
Definition algorithm.hpp:37