Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
AnyItemArray2.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* AnyItemArray2.h (C) 2000-2025 */
9/* */
10/* 2D array of items of arbitrary types. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ANYITEM_ANYITEMARRAY2_H
13#define ARCANE_CORE_ANYITEM_ANYITEMARRAY2_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Array2.h"
18
19#include "arcane/core/IItemFamily.h"
20#include "arcane/core/anyitem/AnyItemGlobal.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane::AnyItem
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
50template <typename DataType>
51class Array2
52{
53 public:
54
55 Array2(const Group& group)
56 : m_size(0)
57 {
58 for (Group::Enumerator e = group.enumerator(); e.hasNext(); ++e) {
59 if (e.groupIndex() >= m_values.size())
60 m_values.resize(e.groupIndex() + 1);
61 }
62 for (Group::Enumerator e = group.enumerator(); e.hasNext(); ++e) {
63 m_values[e.groupIndex()].resize(e.group().itemFamily()->maxLocalId(), m_size);
64 }
65 }
66
68 inline void resize(Integer size)
69 {
70 m_size = size;
71 for (Integer i = 0; i < m_values.size(); ++i) {
72 m_values[i].resize(m_values[i].dim1Size(), m_size);
73 }
74 }
75
77 void fill(const DataType& data)
78 {
79 for (Integer i = 0; i < m_values.size(); ++i) {
80 m_values[i].fill(data);
81 }
82 }
83
85 template <typename T>
86 inline ArrayView<DataType> operator[](const T& item)
87 {
88 return m_values[item.groupIndex()][item.varIndex()];
89 }
90
91 // Accessor
92 template <typename T>
93 inline ConstArrayView<DataType> operator[](const T& item) const
94 {
95 return m_values[item.groupIndex()][item.varIndex()];
96 }
97
99 inline Integer size() const { return m_size; }
100
101 private:
102
105
108};
109
110/*---------------------------------------------------------------------------*/
111/*---------------------------------------------------------------------------*/
112
113} // namespace Arcane::AnyItem
114
115/*---------------------------------------------------------------------------*/
116/*---------------------------------------------------------------------------*/
117
118#endif
Arcane::UniqueArray< Arcane::UniqueArray2< DataType > > m_values
Container for generic variables.
void resize(Integer size)
Resizing the second dimension of the array.
Integer size() const
Returns the size of the array.
ArrayView< DataType > operator[](const T &item)
Accessor.
void fill(const DataType &data)
Filling the array.
Integer m_size
Size of the array's second dimension.
Enumerator of item blocks.
AnyItem Group Aggregation of Arcane group + information {partial or not} for variables Construction w...
Enumerator enumerator() const
Enumerator of the group.
Modifiable view of an array of type T.
Constant view of an array of type T.
1D data vector with value semantics (STL style).
Int32 Integer
Type representing an integer.