22 S99Table(std::vector<std::string> col_names, std::vector<double> data, std::size_t ncols, std::size_t nrows)
23 : col_names_(std::move(col_names)), data_(std::move(data)), ncols_(ncols), nrows_(nrows)
28 std::size_t nrows()
const noexcept {
return nrows_; }
31 std::size_t ncols()
const noexcept {
return ncols_; }
34 double operator()(std::size_t col_ind, std::size_t row_ind)
const noexcept
37 if ((col_ind >= ncols_) or (row_ind >= nrows_)) {
39 "invalid index col_ind, %zu, must be less than %zu and row_ind, %zu, must be "
41 col_ind, ncols_, row_ind, nrows_);
43 return data_[row_ind * ncols_ + col_ind];
47 std::string col_name(std::size_t col_ind)
const noexcept
49 if (col_ind < ncols_)
return col_names_[col_ind];
54 std::size_t col_index(
const std::string& col_name)
const noexcept
56 for (std::size_t i = 0; i < ncols_; i++) {
57 if (col_names_[i] == col_name)
return i;
59 CHOLLA_ERROR(
"the table doesn't hold a column called: \"%s\"", col_name.c_str());
63 std::vector<std::string> col_names_;
64 std::vector<double> data_;