17 #ifndef COM_BORA_SOFTWARE__BALAU_UTIL__CONTAINERS 18 #define COM_BORA_SOFTWARE__BALAU_UTIL__CONTAINERS 37 template <
template <
typename ...>
class DstT,
typename ... D,
template <
typename ...>
class SrcT,
typename ... S,
template <
typename ...>
class ... SrcMT,
typename ... SM>
38 static void append(DstT<D ...> & dst,
const SrcT<S ...> & src,
const SrcMT<SM ...> & ... srcMore) {
39 dst.insert(std::end(dst), std::begin(src), std::end(src));
46 template <
template <
typename ...>
class DstT,
typename ... D,
template <
typename ...>
class SrcT,
typename ... S>
47 static void append(DstT<D ...> & dst,
const SrcT<S ...> & src) {
48 dst.insert(std::end(dst), std::begin(src), std::end(src));
54 template <
template <
typename ...>
class ContainerT,
typename ... C,
template <
typename ...>
class ... ContainerMT,
typename ... M>
55 static ContainerT<C ...>
concatenate(
const ContainerT<C ...> & c,
const ContainerMT<M ...> & ... cMore) {
56 ContainerT<C ...> dst;
64 template <
typename D,
typename S,
template <
typename ...>
class ContainerT,
typename ... DC,
typename ... SC>
65 static ContainerT<D, DC ...>
map(
const ContainerT<S, SC ...> & input, std::function<D (
const S &)> f) {
66 ContainerT<D, DC ...> ret;
67 std::transform(input.begin(), input.end(), std::back_inserter(ret), f);
74 template <
template <
typename ...>
class C,
typename ... T,
typename U>
75 static bool contains(
const C<T ...> & container,
const U & value) {
76 return std::find(container.begin(), container.end(), value) != container.end();
82 template <
template <
typename ...>
class C,
typename ... T,
template <
typename ...>
class V,
typename ... U>
83 static bool contains(
const C<T ...> & container,
const V<U ...> & values) {
84 for (
const auto & value : values) {
85 if (std::find(container.begin(), container.end(), value) != container.end()) {
102 #endif // COM_BORA_SOFTWARE__BALAU_UTIL__CONTAINERS static void append(DstT< D ... > &dst, const SrcT< S ... > &src, const SrcMT< SM ... > &... srcMore)
Appends the source containers to the destination container.
Definition: Containers.hpp:38
Utilities for containers.
Definition: Containers.hpp:31
Pre-defined universal to-string functions.
static bool contains(const C< T ... > &container, const U &value)
Does the container contain the supplied value?
Definition: Containers.hpp:75
static ContainerT< D, DC ... > map(const ContainerT< S, SC ... > &input, std::function< D(const S &)> f)
Perform a map operator (transform the input elements to a container of different elements).
Definition: Containers.hpp:65
static bool contains(const C< T ... > &container, const V< U ... > &values)
Does the container contain one of the supplied values?
Definition: Containers.hpp:83
static ContainerT< C ... > concatenate(const ContainerT< C ... > &c, const ContainerMT< M ... > &... cMore)
Concatenates the containers to form a new container.
Definition: Containers.hpp:55
static void append(DstT< D ... > &dst, const SrcT< S ... > &src)
Appends the source container to the destination container.
Definition: Containers.hpp:47