31#ifndef OPM_FAST_SMALL_VECTOR_HPP
32#define OPM_FAST_SMALL_VECTOR_HPP
46template <
typename ValueType,
unsigned N>
54 dataPtr_ = smallBuf_.data();
69 std::fill(dataPtr_, dataPtr_ + size_, value);
76 dataPtr_ = smallBuf_.data();
85 dataPtr_ = smallBuf_.data();
87 (*this) = std::move(other);
101 smallBuf_ = std::move(other.smallBuf_);
102 dataPtr_ = smallBuf_.data();
105 data_ = std::move(other.data_);
106 dataPtr_ = data_.data();
109 other.dataPtr_ =
nullptr;
121 smallBuf_ = other.smallBuf_;
122 dataPtr_ = smallBuf_.data();
124 else if (dataPtr_ != other.dataPtr_) {
126 dataPtr_ = data_.data();
134 {
return dataPtr_[idx]; }
138 {
return dataPtr_[idx]; }
145 void init_(
size_t numElem)
151 dataPtr_ = data_.data();
153 dataPtr_ = smallBuf_.data();
156 std::array<ValueType, N> smallBuf_;
157 std::vector<ValueType> data_;
An implementation of vector/array based on small object optimization.
Definition FastSmallVector.hpp:48
FastSmallVector()
default constructor
Definition FastSmallVector.hpp:51
size_t size() const
number of the element
Definition FastSmallVector.hpp:141
FastSmallVector & operator=(FastSmallVector &&other)
move assignment
Definition FastSmallVector.hpp:97
FastSmallVector(FastSmallVector &&other)
move constructor
Definition FastSmallVector.hpp:82
const ValueType & operator[](size_t idx) const
const access the idx th element
Definition FastSmallVector.hpp:137
FastSmallVector(const size_t numElem, const ValueType value)
constructor based on the number of the element, and all the elements will have the same value
Definition FastSmallVector.hpp:65
FastSmallVector & operator=(const FastSmallVector &other)
copy assignment
Definition FastSmallVector.hpp:116
~FastSmallVector()
destructor
Definition FastSmallVector.hpp:91
FastSmallVector(const size_t numElem)
constructor based on the number of the element
Definition FastSmallVector.hpp:58
FastSmallVector(const FastSmallVector &other)
copy constructor
Definition FastSmallVector.hpp:73
ValueType & operator[](size_t idx)
access the idx th element
Definition FastSmallVector.hpp:133
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30