YAP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
container_utils.h File Reference
#include <algorithm>

Go to the source code of this file.

Functions

template<class InputIt1 , class InputIt2 , class BinaryPredicate >
bool overlap (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, BinaryPredicate p)
 
template<class InputIt1 , class InputIt2 , class BinaryPredicate >
bool disjoint (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, BinaryPredicate p)
 
template<class InputIt1 , class InputIt2 , class BinaryPredicate >
bool contains (InputIt1 first_haystack, InputIt1 last_haystack, InputIt2 first_needle, InputIt2 last_needle, BinaryPredicate p)
 
template<class InputIt >
const bool orderless_equal (InputIt first1, InputIt last1, InputIt first2, InputIt last2)
 
template<class InputIt >
const bool orderless_contains (InputIt first_haystack, InputIt last_haystack, InputIt first_needle, InputIt last_needle)
 
template<class InputIt >
InputIt ordered_unique (InputIt first, InputIt last)
 
template<class InputIt >
std::vector< std::vector
< typename InputIt::value_type > > 
combinations (InputIt first, InputIt last, size_t n)
 
template<typename T >
bool overlap (const std::vector< T > &A, const std::vector< T > &B)
 check if two vectors overlap More...
 
template<typename T >
bool disjoint (const std::vector< T > &A, const std::vector< T > &B)
 check if two vectors are disjoint
 
template<typename T >
bool contains (const std::vector< T > &A, const std::vector< T > &B)
 check if the first vector contains the second one
 
template<typename T >
std::vector< std::vector< T > > combinations (const std::vector< T > &V, size_t n)
 

Function Documentation

std::vector<std::vector<typename InputIt::value_type> > combinations ( InputIt  first,
InputIt  last,
size_t  n 
)

create vector of combinations (as vectors) of elements between first and last

Parameters
firstIterator to start at
lastIterator beyond point to stop at
nnumber of elements in a combination
Template Parameters
InputItiterator type
bool contains ( InputIt1  first_haystack,
InputIt1  last_haystack,
InputIt2  first_needle,
InputIt2  last_needle,
BinaryPredicate  p 
)

check if first container contains second (no sorting necessary). BinaryPredicate must have signature bool(const InputIt1::type&, const InputIt2::type&)

bool disjoint ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
BinaryPredicate  p 
)

check if two containers are disjoint (no sorting necessary). BinaryPredicate must have signature bool(const InputIt1::type&, const InputIt2::type&)

InputIt ordered_unique ( InputIt  first,
InputIt  last 
)

useful for removing duplicates from an unsorted vector (preserving order of first occurance)

Template Parameters
InputItiterator type
const bool orderless_contains ( InputIt  first_haystack,
InputIt  last_haystack,
InputIt  first_needle,
InputIt  last_needle 
)

equality comparison, checks that haystack contains needle doesn't care about order

const bool orderless_equal ( InputIt  first1,
InputIt  last1,
InputIt  first2,
InputIt  last2 
)

equality comparison cares only of unordered content

bool overlap ( InputIt1  first1,
InputIt1  last1,
InputIt2  first2,
InputIt2  last2,
BinaryPredicate  p 
)

check if two containers overlap (no sorting necessary). BinaryPredicate must have signature bool(const InputIt1::type&, const InputIt2::type&)

bool overlap ( const std::vector< T > &  A,
const std::vector< T > &  B 
)

check if two vectors overlap

Todo:
allow passing of binary predicate with defaulting to lambda