Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
AnyItemArray.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/* AnyItemArray.h (C) 2000-2025 */
9/* */
10/* Array of items of arbitrary types. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ANYITEM_ANYITEMARRAY_H
13#define ARCANE_CORE_ANYITEM_ANYITEMARRAY_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Array.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
48template <typename DataType>
49class Array
50{
51 public:
52
53 Array(const Group& group)
54 {
55 for (Group::Enumerator e = group.enumerator(); e.hasNext(); ++e) {
56 if (e.groupIndex() >= m_values.size())
57 m_values.resize(e.groupIndex() + 1);
58 }
59 for (Group::Enumerator e = group.enumerator(); e.hasNext(); ++e) {
60 m_values[e.groupIndex()].resize(e.group().itemFamily()->maxLocalId());
61 }
62 }
63
65 void fill(const DataType& data)
66 {
67 for (Integer i = 0; i < m_values.size(); ++i) {
68 m_values[i].fill(data);
69 }
70 }
71
73 template <typename T>
74 inline DataType& operator[](const T& item)
75 {
76 return m_values[item.groupIndex()][item.varIndex()];
77 }
78
79 // Accessor
80 template <typename T>
81 inline typename Arcane::UniqueArray<DataType>::ConstReferenceType operator[](const T& item) const
82 {
83 return m_values[item.groupIndex()][item.varIndex()];
84 }
85
86 private:
87
90};
91
92/*---------------------------------------------------------------------------*/
93/*---------------------------------------------------------------------------*/
94
95} // namespace Arcane::AnyItem
96
97/*---------------------------------------------------------------------------*/
98/*---------------------------------------------------------------------------*/
99
100#endif
DataType & operator[](const T &item)
Accessor.
void fill(const DataType &data)
Filling the array.
Arcane::UniqueArray< Arcane::UniqueArray< DataType > > m_values
Container of generic variables.
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.
1D data vector with value semantics (STL style).
Int32 Integer
Type representing an integer.