swift
Loading...
Searching...
No Matches
algorithm.h File Reference

Go to the source code of this file.

Namespaces

namespace  swift::misc
 Free functions in swift::misc.

Functions

template<typename I, typename J>
auto swift::misc::removeIfIn (I begin1, I end1, J begin2, J end2)
 Removes those elements in range 1 that appear also in range 2 leaving only those that do not appear in range 2.
template<typename ForwardIt, typename OutputIt, typename Generator>
void swift::misc::copyRandomElements (ForwardIt in, ForwardIt end, OutputIt out, int n, Generator &&rng)
 Use the random number generator rng to choose n elements from the range [in,end) and copy them to out.
template<typename ForwardIt, typename OutputIt>
void swift::misc::copyRandomElements (ForwardIt in, ForwardIt end, OutputIt out, int n)
 Randomly choose n elements from the range [in,end) and copy them to out.
template<typename ForwardIt, typename OutputIt, typename Generator>
void swift::misc::copySampleElements (ForwardIt in, ForwardIt end, OutputIt out, int n, Generator &&rng)
 Split the range [in,end) into n equal chunks and use the random number generator rng to choose one element from each.
template<typename ForwardIt, typename OutputIt>
void swift::misc::copySampleElements (ForwardIt in, ForwardIt end, OutputIt out, int n)
 Split the range [in,end) into n equal chunks and randomly choose one element from each.
template<typename I, typename F>
void swift::misc::topologicalSort (I begin, I end, F comparator)
 Topological sorting algorithm.
template<typename C, typename T, typename F>
void swift::misc::topologicallySortedInsert (C &container, T &&value, F comparator)
 Insert an element into a sequential container while preserving the topological ordering of the container.
template<typename T, typename F>
void swift::misc::tupleForEachPair (T &&tuple, F &&visitor)
 Invoke a visitor function on each pair of elements of a tuple in order.