26 std::unique_ptr<uint64_t[]> idx;
31 TOC(uint64_t r, uint64_t c) :
32 rows(r), cols(c), idx(std::make_unique<uint64_t[]>(r * c))
35 void print(std::ostream& out = std::cout)
const
37 out <<
"Rows, Cols: " << rows <<
", " << cols << std::endl;
38 for (uint64_t i = 0; i < rows; ++i) {
39 for (uint64_t j = 0; j < cols; ++j) {
40 out <<
getIdx(i, j) <<
" ";
46 uint64_t
getRows()
const {
return this->rows; }
48 uint64_t
getCols()
const {
return this->cols; }
50 uint64_t
getIdx(
int i,
int j)
const {
return this->idx[i * cols + j]; }
52 void setIdx(
int i,
int j, uint64_t value) { this->idx[i * cols + j] = value; }
56 s.write(
reinterpret_cast<char*
>(&rows),
sizeof(uint64_t));
57 s.write(
reinterpret_cast<char*
>(&cols),
sizeof(uint64_t));
58 s.write(
reinterpret_cast<char*
>(idx.get()),
sizeof(uint64_t) * rows * cols);
63 s.read(
reinterpret_cast<char*
>(&rows),
sizeof(uint64_t));
64 s.read(
reinterpret_cast<char*
>(&cols),
sizeof(uint64_t));
66 idx.reset(
new uint64_t[rows * cols]);
67 s.read(
reinterpret_cast<char*
>(idx.get()),
sizeof(uint64_t) * rows * cols);
70 long memorySize() {
return sizeof(uint64_t) * (2 + rows * cols); }