TDMS
Time Domain Maxwell Solver
All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros Pages
tdms_vector_utils Namespace Reference

A collection of utility functions that we will be applying to std::vectors multiple times throughout the codebase. More...

Functions

template<typename T >
max (const std::vector< T > &v)
 Return the maximum value stored in the vector.
 
template<typename T >
bool has_elements (const std::vector< T > &v)
 Return true if the vector has non-zero size.
 
template<typename T >
int index (const std::vector< T > &v, const T &value)
 
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 STORED AS DOUBLES ARE INTS.
 

Detailed Description

A collection of utility functions that we will be applying to std::vectors multiple times throughout the codebase.

Function Documentation

◆ index()

template<typename T >
int tdms_vector_utils::index ( const std::vector< T > &  v,
const T &  value 
)

Get the index of a particular integer in this vector. If it does not exist then return -1. Returns the first occurrence.

Parameters
vVector to search through for the value
valuevalue to find
Returns
index of the value in the vector, or -1 (if not found)

◆ to_vector_int()

std::vector< int > tdms_vector_utils::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 STORED AS DOUBLES ARE INTS.

Usage cases are restricted to when data is read from MATLAB .mat files, which by default save all values as floats, however we are expecting to receive integer values (cell indices, sizes, etc).

Parameters
ints_that_are_doublesVector of doubles that actually contain integer values
Returns
std::vector<int> Converted values