CSet++
Set of defined functions to work with sets
Loading...
Searching...
No Matches
set Namespace Reference

Contains all the functions for performing set operations on std::vector. More...

Functions

template<typename T >
bool contains (const std::vector< T > &k, const T &kk) noexcept
 Checks if an element is present in the set.
 
template<typename T >
int count (const std::vector< T > &k, const T &kk) noexcept
 Counts the number of times an element is present in the set.
 
template<typename T >
std::vector< T > & unique (std::vector< T > &c, const std::vector< T > &k)
 Removes duplicates from a set.
 
template<typename T >
std::vector< T > & unique (std::vector< T > &k)
 Removes duplicates from a set.
 
template<typename T >
std::vector< T > unique (std::vector< T > &&k)
 Removes duplicates from a set.
 
template<typename T >
std::vector< T > & sort (std::vector< T > &c, const std::vector< T > &k)
 Sorts a set in ascending order.
 
template<typename T >
std::vector< T > & sort (std::vector< T > &k)
 Sorts a set in ascending order.
 
template<typename T >
std::vector< T > sort (std::vector< T > &&k)
 Sorts a set in ascending order.
 
template<typename T >
std::vector< T > & rsort (std::vector< T > &c, const std::vector< T > &k)
 Sorts a set in descending order.
 
template<typename T >
std::vector< T > & rsort (std::vector< T > &k)
 Sorts a set in descending order.
 
template<typename T >
std::vector< T > rsort (std::vector< T > &&k)
 Sorts a set in descending order.
 
template<typename T >
std::vector< T > & reverse (std::vector< T > &c, const std::vector< T > &k)
 Reverses the passed set.
 
template<typename T >
std::vector< T > & reverse (std::vector< T > &k)
 Reverses the passed set.
 
template<typename T >
std::vector< T > reverse (std::vector< T > &&k)
 Reverses the passed set.
 
template<typename T >
std::vector< T > & sunion (std::vector< T > &c, const std::vector< T > &k, const std::vector< T > &kk)
 Obtains the set theory union of two sets.
 
template<typename T >
std::vector< T > sunion (const std::vector< T > &k, const std::vector< T > &kk)
 Obtains the set theory union of two sets.
 
template<typename T >
std::vector< T > sunion (std::vector< T > &&k, const std::vector< T > &&kk)
 Obtains the set theory union of two sets.
 
template<typename T >
std::vector< T > & intersection (std::vector< T > &c, const std::vector< T > &k, const std::vector< T > &kk)
 Obtains the set theory intersection of two sets.
 
template<typename T >
std::vector< T > intersection (const std::vector< T > &k, const std::vector< T > &kk)
 Obtains the set theory intersection of two sets.
 
template<typename T >
std::vector< T > intersection (std::vector< T > &&k, const std::vector< T > &&kk)
 Obtains the set theory intersection of two sets.
 
template<typename T >
std::vector< T > & diff (std::vector< T > &c, const std::vector< T > &k, const std::vector< T > &kk)
 Obtains the set theory difference of two sets.
 
template<typename T >
std::vector< T > diff (const std::vector< T > &k, const std::vector< T > &kk)
 Obtains the set theory difference of two sets.
 
template<typename T >
std::vector< T > diff (std::vector< T > &&k, const std::vector< T > &&kk)
 Obtains the set theory difference of two sets.
 
template<typename T >
std::vector< T > & sdiff (std::vector< T > &c, const std::vector< T > &k, const std::vector< T > &kk)
 Obtains the set theory symmetric difference of two sets.
 
template<typename T >
std::vector< T > sdiff (const std::vector< T > &k, const std::vector< T > &kk)
 Obtains the set theory symmetric difference of two sets.
 
template<typename T >
std::vector< T > sdiff (std::vector< T > &&k, const std::vector< T > &&kk)
 Obtains the set theory symmetric difference of two sets.
 

Detailed Description

Contains all the functions for performing set operations on std::vector.

The set namespace contains functions for performing common set operations on std::vector, such as checking if an element is present, counting the number of occurrences, and performing union, intersection, difference and symmetric difference operations.

Function Documentation

◆ contains()

template<typename T >
bool set::contains ( const std::vector< T > &  k,
const T &  kk 
)
inlinenoexcept

Checks if an element is present in the set.

Template Parameters
T- The type of the elements in the set.
Parameters
kThe input set.
kkThe element to check for.
Returns
(true) If kk is present in k.
(false) If kk is not present in k.

Definition at line 300 of file set.h.

◆ count()

template<typename T >
int set::count ( const std::vector< T > &  k,
const T &  kk 
)
inlinenoexcept

Counts the number of times an element is present in the set.

Template Parameters
T- The type of the elements in the set.
Parameters
kThe input set.
kkThe element to count.
Returns
(int) The number of times kk was found in k.

Definition at line 307 of file set.h.

◆ diff() [1/3]

template<typename T >
std::vector< T > set::diff ( const std::vector< T > &  k,
const std::vector< T > &  kk 
)
inline

Obtains the set theory difference of two sets.

Template Parameters
T- The type of the elements in the set.
Parameters
kThe first input set.
kkThe second input set.
Returns
(std::vector<T>) A rvalue set that contains the results.

Definition at line 460 of file set.h.

References diff().

◆ diff() [2/3]

template<typename T >
std::vector< T > set::diff ( std::vector< T > &&  k,
const std::vector< T > &&  kk 
)
inline

Obtains the set theory difference of two sets.

Template Parameters
T- The type of the elements in the set.
Parameters
kThe first rvalue input set.
kkThe second rvalue input set.
Returns
(std::vector<T>) A new vector with the results.

◆ diff() [3/3]

template<typename T >
std::vector< T > & set::diff ( std::vector< T > &  c,
const std::vector< T > &  k,
const std::vector< T > &  kk 
)
inline

Obtains the set theory difference of two sets.

Template Parameters
T- The type of the elements in the set.
Parameters
cThe set on which to store the results.
kThe first input set.
kkThe second input set.
Returns
(std::vector<T>&) A reference to the passed vector c.

Definition at line 453 of file set.h.

References contains().

◆ intersection() [1/3]

template<typename T >
std::vector< T > set::intersection ( const std::vector< T > &  k,
const std::vector< T > &  kk 
)
inline

Obtains the set theory intersection of two sets.

Template Parameters
T- The type of the elements in the set.
Parameters
kThe first input set.
kkThe second input set.
Returns
(std::vector<T>) A rvalue set that contains the results.

Definition at line 437 of file set.h.

References intersection().

◆ intersection() [2/3]

template<typename T >
std::vector< T > set::intersection ( std::vector< T > &&  k,
const std::vector< T > &&  kk 
)
inline

Obtains the set theory intersection of two sets.

Template Parameters
T- The type of the elements in the set.
Parameters
kThe first rvalue input set.
kkThe second rvalue input set.
Returns
(std::vector<T>) A new vector with the results.

◆ intersection() [3/3]

template<typename T >
std::vector< T > & set::intersection ( std::vector< T > &  c,
const std::vector< T > &  k,
const std::vector< T > &  kk 
)
inline

Obtains the set theory intersection of two sets.

Template Parameters
T- The type of the elements in the set.
Parameters
cThe set on which to store the results.
kThe first input set.
kkThe second input set.
Returns
(std::vector<T>&) A reference to the passed vector c.

Definition at line 429 of file set.h.

References contains().

◆ reverse() [1/3]

template<typename T >
std::vector< T > set::reverse ( std::vector< T > &&  k)
inline

Reverses the passed set.

Template Parameters
T- The type of the elements in the set.
Parameters
kThe rvalue set which is to be modified.
Returns
(std::vector<T>) A new vector with the results.

Definition at line 398 of file set.h.

◆ reverse() [2/3]

template<typename T >
std::vector< T > & set::reverse ( std::vector< T > &  c,
const std::vector< T > &  k 
)
inline

Reverses the passed set.

Template Parameters
T- The type of the elements in the set.
Parameters
cThe set on which to store the results.
kThe input set.
Returns
(std::vector<T>&) A reference to the passed vector c.2

Definition at line 383 of file set.h.

◆ reverse() [3/3]

template<typename T >
std::vector< T > & set::reverse ( std::vector< T > &  k)
inline

Reverses the passed set.

Template Parameters
T- The type of the elements in the set.
Parameters
kThe set which is to be modified.
Returns
(std::vector<T>&) A reference to the passed vector k.

Definition at line 391 of file set.h.

◆ rsort() [1/3]

template<typename T >
std::vector< T > set::rsort ( std::vector< T > &&  k)
inline

Sorts a set in descending order.

Template Parameters
T- The type of the elements in the set.
Parameters
kThe rvalue set which is to be modified.
Returns
(std::vector<T>) A new vector with the results.

Definition at line 376 of file set.h.

◆ rsort() [2/3]

template<typename T >
std::vector< T > & set::rsort ( std::vector< T > &  c,
const std::vector< T > &  k 
)
inline

Sorts a set in descending order.

Template Parameters
T- The type of the elements in the set.
Parameters
cThe set on which to store the results.
kThe input set.
Returns
(std::vector<T>&) A reference to the passed vector c.

Definition at line 361 of file set.h.

◆ rsort() [3/3]

template<typename T >
std::vector< T > & set::rsort ( std::vector< T > &  k)
inline

Sorts a set in descending order.

Template Parameters
T- The type of the elements in the set.
Parameters
kThe set which is to be modified.
Returns
(std::vector<T>&) A reference to the passed vector k.

Definition at line 369 of file set.h.

◆ sdiff() [1/3]

template<typename T >
std::vector< T > set::sdiff ( const std::vector< T > &  k,
const std::vector< T > &  kk 
)
inline

Obtains the set theory symmetric difference of two sets.

Template Parameters
T- The type of the elements in the set.
Parameters
kThe first input set.
kkThe second input set.
Returns
(std::vector<T>) A rvalue set that contains the results.

Definition at line 484 of file set.h.

References sdiff().

◆ sdiff() [2/3]

template<typename T >
std::vector< T > set::sdiff ( std::vector< T > &&  k,
const std::vector< T > &&  kk 
)
inline

Obtains the set theory symmetric difference of two sets.

Template Parameters
T- The type of the elements in the set.
Parameters
kThe first rvalue input set.
kkThe second rvalue input set.
Returns
(std::vector<T>) A new vector with the results.

◆ sdiff() [3/3]

template<typename T >
std::vector< T > & set::sdiff ( std::vector< T > &  c,
const std::vector< T > &  k,
const std::vector< T > &  kk 
)
inline

Obtains the set theory symmetric difference of two sets.

Template Parameters
T- The type of the elements in the set.
Parameters
cThe set on which to store the results.
kThe first input set.
kkThe second input set.
Returns
(std::vector<T>&) A reference to the passed vector c.

Definition at line 476 of file set.h.

References diff().

◆ sort() [1/3]

template<typename T >
std::vector< T > set::sort ( std::vector< T > &&  k)
inline

Sorts a set in ascending order.

Template Parameters
T- The type of the elements in the set.
Parameters
kThe rvalue set which is to be modified.
Returns
(std::vector<T>) A new vector with the results.

Definition at line 354 of file set.h.

◆ sort() [2/3]

template<typename T >
std::vector< T > & set::sort ( std::vector< T > &  c,
const std::vector< T > &  k 
)
inline

Sorts a set in ascending order.

Template Parameters
T- The type of the elements in the set.
Parameters
cThe set on which to store the results.
kThe input set.
Returns
(std::vector<T>&) A reference to the passed vector c.

Definition at line 339 of file set.h.

◆ sort() [3/3]

template<typename T >
std::vector< T > & set::sort ( std::vector< T > &  k)
inline

Sorts a set in ascending order.

Template Parameters
T- The type of the elements in the set.
Parameters
kThe set which is to be modified.
Returns
(std::vector<T>&) A reference to the passed vector k.

Definition at line 347 of file set.h.

◆ sunion() [1/3]

template<typename T >
std::vector< T > set::sunion ( const std::vector< T > &  k,
const std::vector< T > &  kk 
)
inline

Obtains the set theory union of two sets.

Template Parameters
T- The type of the elements in the set.
Parameters
kThe first input set.
kkThe second input set.
Returns
(std::vector<T>) A rvalue set that contains the results.

Definition at line 413 of file set.h.

References sunion().

◆ sunion() [2/3]

template<typename T >
std::vector< T > set::sunion ( std::vector< T > &&  k,
const std::vector< T > &&  kk 
)
inline

Obtains the set theory union of two sets.

Template Parameters
T- The type of the elements in the set.
Parameters
kThe first rvalue input set.
kkThe second rvalue input set.
Returns
(std::vector<T>) A new vector with the results.

◆ sunion() [3/3]

template<typename T >
std::vector< T > & set::sunion ( std::vector< T > &  c,
const std::vector< T > &  k,
const std::vector< T > &  kk 
)
inline

Obtains the set theory union of two sets.

Template Parameters
T- The type of the elements in the set.
Parameters
cThe set on which to store the results.
kThe first input set.
kkThe second input set.
Returns
(std::vector<T>&) A reference to the passed vector c.

Definition at line 405 of file set.h.

References contains().

◆ unique() [1/3]

template<typename T >
std::vector< T > set::unique ( std::vector< T > &&  k)
inline

Removes duplicates from a set.

Template Parameters
T- The type of the elements in the set.
Parameters
kThe rvalue set which is to be modified.
Returns
(std::vector<T>) A new vector with the results.

Definition at line 331 of file set.h.

References unique().

◆ unique() [2/3]

template<typename T >
std::vector< T > & set::unique ( std::vector< T > &  c,
const std::vector< T > &  k 
)
inline

Removes duplicates from a set.

Template Parameters
T- The type of the elements in the set.
Parameters
cThe set on which to store the results.
kThe input set.
Returns
(std::vector<T>&) A reference to the passed vector c.

Definition at line 315 of file set.h.

References contains().

◆ unique() [3/3]

template<typename T >
std::vector< T > & set::unique ( std::vector< T > &  k)
inline

Removes duplicates from a set.

Template Parameters
T- The type of the elements in the set.
Parameters
kThe set which is to be modified.
Returns
(std::vector<T>&) A reference to the passed vector k.

Definition at line 322 of file set.h.

References unique().