What is the correct name for a container which can handle invalid entries, think NaN or missing data. Since I am not the first one to encounter this problem, I assume that there is a naming scheme in place.
ContainerMissingValues, ContainerNaN, ContainerValidData, ...
Update: following the naming convention in linear algebra and computer vision for dense and sparse vectors, I call this structure a SemiSparseVector.
Example
(-1 represent invalid entries)
#include <iostream>
#include <vector>
template<class T>
struct SemiSparseVector {
auto get() -> const std::vector<T>& {
return vec;
};
auto getWithoutMissingValues() -> std::vector<T> {
std::vector<T> vec_without_missing_values;
for ( auto v : vec ) {
if(v != -1) {
vec_without_missing_values.push_back(v);
}
}
return vec_without_missing_values;
};
std::vector<T> vec;
};
template<class T>
void printVec(const std::vector<T>& vec) {
for ( auto v : vec ) {
std::cout << v << ", ";
}
std::cout << std::endl;
}
int main()
{
SemiSparseVector<int> semi_sparse_vector;
semi_sparse_vector.vec = std::vector{ -1, 3, 5, -1 };
printVec(semi_sparse_vector.get());
printVec(semi_sparse_vector.getWithoutMissingValues());
return 0;
}