qxLib
Functions
add.h File Reference
#include <qx/algo/contains.h>
#include <type_traits>

Go to the source code of this file.

Functions

template<class container_t , class value_t >
bool qx::add_unique (container_t &container, value_t &&value)
 Add an element to the container if it doesn't already contain one. More...
 
template<class container_t , class value_t , class predicate_t >
bool qx::add_unique_if (container_t &container, value_t &&value, const predicate_t &predicate)
 Add an element to the container if all elements do not satisfy the predicate. More...
 

Detailed Description

Author
Khrapov
Date
14.08.2022

Definition in file add.h.

Function Documentation

◆ add_unique()

template<class container_t , class value_t >
bool qx::add_unique ( container_t &  container,
value_t &&  value 
)

Add an element to the container if it doesn't already contain one.

Template Parameters
container_t- container type
value_t- value type
Parameters
container- container to add to
value- value to check and add
Return values
-true if value was added

Definition at line 27 of file add.h.

◆ add_unique_if()

template<class container_t , class value_t , class predicate_t >
bool qx::add_unique_if ( container_t &  container,
value_t &&  value,
const predicate_t &  predicate 
)

Add an element to the container if all elements do not satisfy the predicate.

Template Parameters
container_t- container type
value_t- value type
predicate_t- predicate type which can be called with (element, value) or (element) only
Parameters
container- container to add to
value- value to check and add
predicate- predicate object
Return values
-true if value was added

Definition at line 51 of file add.h.