Commit 61847b9d authored by Marko Mäkelä's avatar Marko Mäkelä

Tablespace: Add iterator, const_iterator, begin(), end()

parent 5ad46457
......@@ -39,11 +39,8 @@ bool
Tablespace::intersection(
const Tablespace* other_space)
{
files_t::const_iterator end = other_space->m_files.end();
for (files_t::const_iterator it = other_space->m_files.begin();
it != end;
++it) {
for (files_t::const_iterator it(other_space->begin()),
end(other_space->end()); it != end; ++it) {
if (find(it->m_filename)) {
......@@ -58,9 +55,7 @@ Tablespace::intersection(
void
Tablespace::shutdown()
{
files_t::iterator end = m_files.end();
for (files_t::iterator it = m_files.begin(); it != end; ++it) {
for (iterator it = begin(); it != end(); ++it) {
it->shutdown();
}
......@@ -95,10 +90,7 @@ Tablespace::open_or_create(bool is_temp)
ut_ad(!m_files.empty());
files_t::iterator begin = m_files.begin();
files_t::iterator end = m_files.end();
for (files_t::iterator it = begin; it != end; ++it) {
for (iterator it = begin(); it != end(); ++it) {
if (it->m_exists) {
err = it->open_or_create(
......@@ -124,7 +116,7 @@ Tablespace::open_or_create(bool is_temp)
the proper way. */
it->close();
if (it == begin) {
if (it == begin()) {
/* First data file. */
/* Create the tablespace entry for the multi-file
......@@ -154,11 +146,9 @@ Tablespace::open_or_create(bool is_temp)
/** Find a filename in the list of Datafiles for a tablespace
@return true if the filename exists in the data files */
bool
Tablespace::find(const char* filename)
Tablespace::find(const char* filename) const
{
files_t::const_iterator end = m_files.end();
for (files_t::const_iterator it = m_files.begin(); it != end; ++it) {
for (const_iterator it = begin(); it != end(); ++it) {
if (innobase_strcasecmp(filename, it->m_filename) == 0) {
return(true);
......@@ -172,9 +162,7 @@ Tablespace::find(const char* filename)
void
Tablespace::delete_files()
{
files_t::iterator end = m_files.end();
for (files_t::iterator it = m_files.begin(); it != end; ++it) {
for (iterator it = begin(); it != end(); ++it) {
it->close();
......
......@@ -44,6 +44,10 @@ class Tablespace {
/** Data file information - each Datafile can be accessed globally */
files_t m_files;
/** Data file iterator */
typedef files_t::iterator iterator;
/** Data file iterator */
typedef files_t::const_iterator const_iterator;
Tablespace()
:
......@@ -68,6 +72,15 @@ class Tablespace {
Tablespace(const Tablespace&);
Tablespace& operator=(const Tablespace&);
/** Data file iterator */
const_iterator begin() const { return m_files.begin(); }
/** Data file iterator */
const_iterator end() const { return m_files.end(); }
/** Data file iterator */
iterator begin() { return m_files.begin(); }
/** Data file iterator */
iterator end() { return m_files.end(); }
void set_name(const char* name) { m_name = name; }
const char* name() const { return m_name; }
......@@ -156,8 +169,7 @@ class Tablespace {
{
ulint sum = 0;
for (files_t::const_iterator it = m_files.begin();
it != m_files.end(); ++it) {
for (const_iterator it = begin(); it != end(); ++it) {
sum += it->m_size;
}
......@@ -200,7 +212,7 @@ class Tablespace {
/**
@param[in] filename Name to lookup in the data files.
@return true if the filename exists in the data files */
bool find(const char* filename);
bool find(const char* filename) const;
/** Note that the data file was found.
@param[in] file data file object */
......
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