rsl 1.1.0
ROS Support Library
Loading...
Searching...
No Matches
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:
 
template<typename Collection >
auto rsl::is_unique (Collection collection)
 Determine if all elements in a collection are unique. Example usage:
 

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

◆ 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

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.