28bool are_equal(
const char *a,
const char *b);
37T
max(
const std::vector<T> &v) {
38 return *std::max_element(v.begin(), v.end());
37T
max(
const std::vector<T> &v) {
…}
55int index(
const std::vector<T> &v,
const T &value) {
56 auto found_index = std::find(v.begin(), v.end(), value);
58 if (found_index == v.end()) {
62 return std::distance(v.begin(), found_index);
55int index(
const std::vector<T> &v,
const T &value) {
…}
A collection of utility functions that we will be applying to std::vectors multiple times throughout ...
Definition utils.h:34
bool has_elements(const std::vector< T > &v)
Return true if the vector has non-zero size.
Definition utils.h:43
T max(const std::vector< T > &v)
Return the maximum value stored in the vector.
Definition utils.h:37
std::vector< int > to_vector_int(const std::vector< double > &ints_that_are_doubles)
Static_casts an array of doubles to ints. ONLY INTENDED FOR CASES WHERE WE KNOW THAT THE VALUES STORE...
int index(const std::vector< T > &v, const T &value)
Definition utils.h:55
bool are_equal(const char *a, const char *b)
Check two strings are equal.
Definition utils.cpp:21
void assert_can_open_file(const char *filename, const char *mode)
Throws a runtime error if a file is not found.
Definition utils.cpp:10