Incorporation of comments from code review.

This commit is contained in:
John Tramm 2020-01-27 17:02:39 +00:00
parent 48a550aaf7
commit 02470bc630
8 changed files with 43 additions and 41 deletions

View file

@ -4,7 +4,7 @@
//! \file shared_array.h
//! \brief Shared array data structure
#include<memory>
#include <memory>
namespace openmc {
@ -24,14 +24,6 @@ namespace openmc {
template <typename T>
class SharedArray {
private:
//==========================================================================
// Data members
std::unique_ptr<T[]> data_; //!< A pointer to hold the data
int64_t size_ {0}; //!< The current size of the SharedArray.
int64_t capacity_ {0}; //!< The maximum capacity of the SharedArray.
public:
//==========================================================================
// Constructors
@ -55,6 +47,7 @@ public:
//! Return a reference to the element at specified location i. No bounds
//! checking is performed.
T& operator[](int64_t i) {return data_[i];}
const T& operator[](int64_t i) const { return data_[i]; }
//! Allocate space in the container for the specified number of elements.
//! reserve() does not change the size of the container.
@ -116,6 +109,15 @@ public:
//! Return pointer to the underlying array serving as element storage.
T* data() {return data_.get();}
const T* data() const {return data_.get();}
private:
//==========================================================================
// Data members
std::unique_ptr<T[]> data_; //!< A pointer to hold the data
int64_t size_ {0}; //!< The current size of the SharedArray.
int64_t capacity_ {0}; //!< The maximum capacity of the SharedArray.
};