45 using BaseClass::BaseClass;
49 using Pointer = std::shared_ptr<OrderedPointSet<T>>;
73 assert(x <
width_ &&
"x out of range");
74 assert(y *
width_ + x <
data_.size() &&
"(x, y) out of range");
81 assert(x <
width_ &&
"x out of range");
82 assert(y *
width_ + x <
data_.size() &&
"(x, y) out of range");
111 auto msg =
"Cannot change width if already set";
112 throw std::logic_error(msg);
132 assert(points.size() ==
width_ &&
"row incorrect size");
134 std::begin(points), std::end(points), std::back_inserter(
data_));
140 assert(points.size() ==
width_ &&
"row incorrect size");
142 std::begin(points), std::end(points), std::back_inserter(
data_));
147 void push_back(
const T& val) =
delete;
148 void push_back(T&& val) =
delete;
149 void emplace_back(
const T& val) =
delete;
150 void emplace_back(T&& val) =
delete;
162 auto msg =
"Cannot append pointset with different width";
163 throw std::logic_error(msg);
166 std::copy(std::begin(ps), std::end(ps), std::back_inserter(
data_));
173 std::vector<T>
getRow(std::size_t i)
const
175 if (i >= this->
height()) {
176 throw std::range_error(
"get row: i out of range");
178 std::vector<T> row(
width_);
181 std::begin(
data_) +
width_ * (i + 1), std::begin(row));
195 if (i >= this->
height()) {
196 throw std::range_error(
"copy row: i out of range");
199 throw std::range_error(
"copy row: j out of range");
205 throw std::logic_error(
"i must be less than j");
210 std::back_inserter(ps.
data_));
223 v.assign(
width, initVal);
224 for (std::size_t _ = 0; _ <
height; ++_) {
Holds a collection of ordered points.
std::size_t height() const
Return the number of rows in the OrderedPointSet.
OrderedPointSet copyRows(std::size_t i, std::size_t j) const
Get multiple rows of points.
T & operator()(std::size_t y, std::size_t x)
Get a point from the OrderedPointSet at row y, column x.
std::vector< T > getRow(std::size_t i) const
Get a row of points.
void setWidth(std::size_t width)
Set the ordering width.
static OrderedPointSet Fill(std::size_t width, std::size_t height, T initVal)
Create an OrderedPointSet of a specific size, filled with an initial value.
void pushRow(std::vector< T > &&points)
Add a row of points to the OrderedPointSet.
void pushRow(const std::vector< T > &points)
Add a row of points to the OrderedPointSet.
void append(const OrderedPointSet< T > &ps)
Append an OrderedPointSet to the end of the current one.
static constexpr std::size_t CAPACITY_MULTIPLIER
void reset()
Like clear(), but zeroes the OrderedPointSet width so that it can be redefined.
OrderedPointSet(std::size_t width)
Constructor with width parameter.
const T & operator()(std::size_t y, std::size_t x) const
Get a point from the OrderedPointSet at row y, column x.
std::size_t width() const
Return the number of columns in the OrderedPointSet.
OrderedPointSet()=default
Default constructor.
std::shared_ptr< OrderedPointSet< T > > Pointer
OrderedPointSet(std::size_t width, T initVal)
Constructor with width parameter and initialization value.
Holds a collection of points.
std::size_t size() const
Get the size of the PointSet.
void clear()
Remove all elements from the PointSet.
Volume Cartographer library