A toolkit for working with phylogenetic data.
v0.24.0
algorithm.hpp File Reference

Detailed Description

Provides some valuable algorithms that are not part of the C++ 11 STL.

Definition in file algorithm.hpp.

#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <numeric>
#include <unordered_set>
#include <utility>
#include <vector>

Go to the source code of this file.

Namespaces

 genesis
 Container namespace for all symbols of genesis in order to keep them separate when used as a library.
 
 genesis::utils
 

Functions

template<class ForwardIt , class T , class Compare = std::less<T>>
ForwardIt binary_find (ForwardIt first, ForwardIt last, const T &value, Compare comp={})
 Binary search on a sorted/partitioned range, returns an iterator to the element if found. More...
 
template<class C , class T >
bool contains (const C &v, const T &x)
 Returns whether a container object has a certain element. More...
 
template<class C >
bool contains_duplicates (C const &v)
 Return whether a container contains duplicates. More...
 
template<class Container , class UnaryPredicate >
void erase_if (Container &c, UnaryPredicate p)
 Erases all elements from the container that satisfy a given predicate. An element is erased, if the predicate evaluates to true for it. The predicate needs to have a signature similar to (T const&)->bool. More...
 
template<typename T >
std::vector< T >::iterator insert_sorted (std::vector< T > &vec, T const &item)
 Insert into a vector vec, sorted by the value of the item. The vector must already be sorted. More...
 
template<typename T , typename Pred >
std::vector< T >::iterator insert_sorted (std::vector< T > &vec, T const &item, Pred pred)
 Insert into a vector vec, sorted by the value of the item, using a predicate. The vector must already be sorted according to the predicate. More...
 
template<class T >
std::pair< T, T > minmax_value (T const &a, T const &b)
 Returns the lowest and the greatest of the given values, by value. More...
 
template<class T , class Compare >
std::pair< T, T > minmax_value (T const &a, T const &b, Compare comp)
 Returns the lowest and the greatest of the given values, by value. More...
 
template<typename RandomAccessIterator , typename Comparator >
std::vector< size_t > sort_indices (RandomAccessIterator first, RandomAccessIterator last, Comparator comparator)
 Get the indices to the sorted order of the given range. More...
 
template<typename RandomAccessIterator >
std::vector< size_t > sort_indices (RandomAccessIterator first, RandomAccessIterator last)
 Get the indices to the sorted order of the given range. More...
 
template<typename RandomAccessIterator , typename Comparator >
std::vector< size_t > stable_sort_indices (RandomAccessIterator first, RandomAccessIterator last, Comparator comparator)
 Get the indices to the stable sorted order of the given range. More...
 
template<typename RandomAccessIterator >
std::vector< size_t > stable_sort_indices (RandomAccessIterator first, RandomAccessIterator last)
 Get the indices to the stable sorted order of the given range. More...