Some checks failed
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 10m11s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 10m22s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 10m27s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 8m19s
Build Packages / Generate python client (push) Successful in 17s
Build Packages / Build documentation (push) Successful in 42s
Build Packages / Create release (push) Has been skipped
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 8m44s
Build Packages / build:rpm (rocky8) (push) Successful in 8m44s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 8m33s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 9m11s
Build Packages / build:rpm (rocky9) (push) Successful in 9m54s
Build Packages / Unit tests (push) Failing after 1h11m12s
This is an UNSTABLE release and not recommended for production use (please use rc.111 instead). * jfjoch_broker: Add binary export of data analysis plots over OpenAPI * jfjoch_broker: Minor fixes to HTTP error handling * jfjoch_viewer: Prefer binary plots over JSON plots * jfjoch_viewer: Change foreground with F button + wheel * jfjoch_viewer: Change way how angles are displayed * jfjoch_viewer: Display resolution of the mouse cursor in top left corner Reviewed-on: #26 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch> Co-committed-by: Filip Leonarski <filip.leonarski@psi.ch>
54 lines
1.4 KiB
C++
54 lines
1.4 KiB
C++
// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#ifndef JFJOCH_AUTOINCRVECTOR_H
|
|
#define JFJOCH_AUTOINCRVECTOR_H
|
|
|
|
#include <vector>
|
|
#include "JFJochException.h"
|
|
|
|
template <class T>
|
|
class AutoIncrVector {
|
|
std::vector<T> v;
|
|
public:
|
|
T& operator[](int64_t pos ) {
|
|
if (pos < 0)
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Negative vector pos");
|
|
if (pos >= v.size())
|
|
v.resize(pos + 1);
|
|
return v[pos];
|
|
}
|
|
|
|
const T& operator[](int64_t pos) const {
|
|
if (pos < 0)
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Negative vector pos");
|
|
if (pos >= v.size())
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Vector pos out of bounds");
|
|
return v[pos];
|
|
}
|
|
|
|
void reserve(int64_t size) {
|
|
if (size < 0)
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Negative size for std::vector reserve");
|
|
v.reserve(size);
|
|
}
|
|
|
|
const std::vector<T> &vec() const {
|
|
return v;
|
|
}
|
|
|
|
auto size() const {
|
|
return v.size();
|
|
}
|
|
|
|
bool empty() const {
|
|
return v.empty();
|
|
}
|
|
|
|
void Clear() {
|
|
v.clear();
|
|
}
|
|
};
|
|
|
|
#endif //JFJOCH_AUTOINCRVECTOR_H
|