Commit 7ca80a0c authored by Kohei Yoshida's avatar Kohei Yoshida

Use deque to store worksheet instances.

This is also to reduce level of indirection.
parent 9fcd740e
Pipeline #43502575 passed with stage
in 3 minutes and 59 seconds
......@@ -38,17 +38,14 @@ workbook::workbook() {}
workbook::workbook(size_t sheet_size, size_t row_size, size_t col_size)
{
for (size_t i = 0; i < sheet_size; ++i)
m_sheets.push_back(new worksheet(row_size, col_size));
m_sheets.emplace_back(row_size, col_size);
}
workbook::~workbook()
{
std::for_each(m_sheets.begin(), m_sheets.end(), default_deleter<worksheet>());
}
workbook::~workbook() {}
void workbook::push_back(size_t row_size, size_t col_size)
{
m_sheets.push_back(new worksheet(row_size, col_size));
m_sheets.emplace_back(row_size, col_size);
}
size_t workbook::size() const
......@@ -62,4 +59,5 @@ bool workbook::empty() const
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -59,11 +59,11 @@ public:
workbook(size_t sheet_size, size_t row_size, size_t col_size);
~workbook();
worksheet& operator[](size_t n) { return *m_sheets[n]; }
const worksheet& operator[](size_t n) const { return *m_sheets[n]; }
worksheet& operator[](size_t n) { return m_sheets[n]; }
const worksheet& operator[](size_t n) const { return m_sheets[n]; }
worksheet& at(size_t n) { return *m_sheets.at(n); }
const worksheet& at(size_t n) const { return *m_sheets.at(n); }
worksheet& at(size_t n) { return m_sheets.at(n); }
const worksheet& at(size_t n) const { return m_sheets.at(n); }
void push_back(size_t row_size, size_t col_size);
......@@ -71,7 +71,7 @@ public:
bool empty() const;
private:
std::vector<worksheet*> m_sheets;
std::deque<worksheet> m_sheets;
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment