48class Array :
public std::vector<base> {
51 Array() : std::vector<base>() {}
55 Array(
Index n,
const base& fillvalue) : std::vector<base>(n) {
56 std::fill(this->begin(), this->end(), fillvalue);
61 Array(
Array&& A) noexcept : std::vector<base>(std::move(A)) {}
63 Array(std::initializer_list<base> init) : std::vector<base>(init) {}
65 template <
class base2,
size_t N>
66 explicit Array(
const std::array<base2, N>& input)
67 : std::vector<base>(input.begin(), input.end()) {
68 static_assert(std::is_convertible<base2, base>::value,
69 "Must be convertible");
72 Array(std::vector<base> x) : std::vector<base>(std::move(x)) {}
76 std::fill(this->begin(), this->end(), x);
81 this->resize(A.size());
82 std::copy(A.begin(), A.end(), this->begin());
87 std::vector<base>::operator=(std::move(A));
93 size_t s = this->size();
95 return static_cast<Index>(s);
102 return std::vector<base>::operator[](n);
108 return std::vector<base>::operator[](n);
113 for (
Index i = 0; i < n; i++) std::vector<base>::push_back(elem);
119 typename Array::const_iterator i =
v.begin();
120 const typename Array::const_iterator end =
v.end();
123 os << std::setw(3) << *i;
127 for (; i != end; ++i) {
128 os <<
" " << std::setw(3) << *i;
152 for (; xi != xe; ++xi) {
168 for (; xi != xe; ++xi) {
192 if (
w == x[i])
return i;
215 if (
w == x[i]) pos.push_back(i);
243 for (
Index i = 0; i < aa.nelem(); i++) {
244 N_aa += aa[i].nelem();
259 for (
Index i = 0; i < outer; i++) {
271template <
typename T,
typename... Ts>
272constexpr std::array<T, 1 +
sizeof...(Ts)>
stdarrayify(
const T& first,
273 const Ts&... the_rest) {
274 return {first, T(the_rest)...};
279 const char*
const sep =
" ",
280 const char*
const beg =
"") {
281 std::ostringstream os;
282 for (
auto& x : list) os << beg << x << sep;
std::string stringify(const Array< T > &list, const char *const sep=" ", const char *const beg="")
Index TotalNumberOfElements(const Array< Array< base > > &aa)
Determine total number of elements in an ArrayOfArray.
Index FlattenedIndex(const Array< Array< base > > &aa, Index outer, Index inner=0)
Determine the index of an element in a flattened version of the array.
Index find_first(const Array< base > &x, const base &w)
Find first occurance.
base max(const Array< base > &x)
Max function.
base min(const Array< base > &x)
Min function.
void find_all(ArrayOfIndex &pos, const Array< base > &x, const base &w)
Find all occurances.
constexpr std::array< T, 1+sizeof...(Ts)> stdarrayify(const T &first, const Ts &... the_rest)
Make a std::array of a list of variables (must be 1-long at least)
This can be used to make arrays out of anything.
Array(Index n, const base &fillvalue)
Array(const std::array< base2, N > &input)
Array & operator=(base x)
void push_back_n(const base &elem, const Index n)
Array(std::vector< base > x)
Array & operator=(const Array &A)
base & operator[](const Index n)
friend std::ostream & operator<<(std::ostream &os, const Array &v)
Array(std::initializer_list< base > init)
const base & operator[](const Index n) const
Index nelem() const ARTS_NOEXCEPT
Array & operator=(Array &&A) noexcept
Array(Array &&A) noexcept
Helper comparison class to sort an array or vector based on an ArrayOfNumeric.
CmpArrayOfNumeric(const ArrayOfNumeric &vec)
const ArrayOfNumeric & values
bool operator()(const int &a, const int &b) const
#define ARTS_ASSERT(condition,...)
INDEX Index
The type to use for all integer numbers and indices.