rsl  1.1.0
ROS Support Library
algorithm.hpp File Reference
#include <algorithm>

Go to the source code of this file.

Functions

template<typename Collection >
auto rsl::contains (Collection const &collection, typename Collection::const_reference value)
 Determine if a collection contains a value. Example usage: More...
 
template<typename Collection >
auto rsl::is_unique (Collection collection)
 Determine if all elements in a collection are unique. Example usage: More...
 

Function Documentation

◆ contains()

template<typename Collection >
auto rsl::contains ( Collection const &  collection,
typename Collection::const_reference  value 
)

Determine if a collection contains a value. Example usage:

auto values = std::vector{1, 2, 3};
rsl::contains(values, 3); // true
rsl::contains(values, -1); // false
auto contains(Collection const &collection, typename Collection::const_reference value)
Determine if a collection contains a value. Example usage:
Definition: algorithm.hpp:19

◆ is_unique()

template<typename Collection >
auto rsl::is_unique ( Collection  collection)

Determine if all elements in a collection are unique. Example usage:

rsl::is_unique(std::vector{2,2}); // false
rsl::is_unique(std::vector{1,2,3}); // true
auto is_unique(Collection collection)
Determine if all elements in a collection are unique. Example usage:
Definition: algorithm.hpp:37

Because of how this function is implemented, the collection parameter is taken by value, creating a copy. The implication of this is that it will not work on collections of non-copy-able objects.