Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ItemIndexArrayView.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/* ItemIndexArrayView.h (C) 2000-2025 */
9/* */
10/* View over an index array (localIds()) of entities. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ITEMINDEXARRAYVIEW_H
13#define ARCANE_CORE_ITEMINDEXARRAYVIEW_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/ArrayView.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
40class ARCANE_CORE_EXPORT ItemIndexArrayView
41{
42 // NOTE: This class is mapped in C# and if its structure is changed, it
43 // must update the corresponding C# version.
44 friend ItemVectorView;
45 friend ItemGroup;
46 template <int Extent> friend class ItemConnectedListView;
47 template <typename ItemType, int Extent> friend class ItemConnectedListViewT;
48 template <typename ItemType> friend class ItemVectorViewT;
49
50 public:
51
52 // NOTE: If values are added here, it must be checked whether they should be
53 // propagated in methods such as subView().
54 enum
55 {
56 F_Contiguous = 1 << 1,
57 F_Contigous = F_Contiguous
58 };
59
60 public:
61
63 ItemIndexArrayView() = default;
64
65 // TODO: To be removed
67 explicit ItemIndexArrayView(const Int32ConstArrayView local_ids)
68 : m_view(local_ids, 0)
69 {}
70
72 : m_view(view)
73 {
74 }
75
76 public:
77
79 inline Int32 operator[](Integer index) const
80 {
81 return m_view.localId(index);
82 }
83
85 Int32 size() const
86 {
87 return m_view.size();
88 }
89
91 void fillLocalIds(Array<Int32>& ids) const;
92
94 inline ItemIndexArrayView subView(Integer abegin, Integer asize) const
95 {
96 // The F_Contiguous flag is propagated to the sub-view.
97 // For other flags, it will be necessary to check if they should be propagated.
98 return ItemIndexArrayView(m_view._idsWithoutOffset().subView(abegin, asize), m_view.m_local_id_offset, m_flags);
99 }
100
101 Int32 flags() const
102 {
103 return m_flags;
104 }
105
106 bool isContigous() const { return isContiguous(); }
107
109 bool isContiguous() const
110 {
111 return m_flags & F_Contigous;
112 }
113
114 friend std::ostream& operator<<(std::ostream& o, const ItemIndexArrayView& a)
115 {
116 o << a.m_view;
117 return o;
118 }
119
120 public:
121
122 // TODO Deprecate (3.11+)
125 {
126 return m_view._idsWithoutOffset();
127 }
128
129 ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane. Do not use it")
130 operator Int32ConstArrayView() const
131 {
132 return _localIds();
133 }
134
135 private:
136
137 ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane. Do not use it")
138 const Int32* unguardedBasePointer() const
139 {
140 return _data();
141 }
142
143 ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane. Do not use it")
144 const Int32* data() const
145 {
146 return _data();
147 }
148
149 protected:
150
151 impl::ItemLocalIdListContainerView m_view;
152 Int32 m_flags = 0;
153
154 private:
155
156 ItemIndexArrayView(SmallSpan<const Int32> local_ids, Int32 local_id_offset, Int32 aflags)
157 : m_view(local_ids, local_id_offset)
158 , m_flags(aflags)
159 {}
160
161 const Int32* _data() const
162 {
163 return m_view.m_local_ids;
164 }
165
166 Int32ConstArrayView _localIds() const
167 {
168 return m_view._idsWithoutOffset();
169 }
170 Int32 _localIdOffset() const
171 {
172 return m_view.m_local_id_offset;
173 }
174};
175
176/*---------------------------------------------------------------------------*/
177/*---------------------------------------------------------------------------*/
178
179} // End namespace Arcane
180
181/*---------------------------------------------------------------------------*/
182/*---------------------------------------------------------------------------*/
183
184#endif
Declarations of types used in Arcane.
Base class for 1D data vectors.
View over an index array (localIds()) of entities.
bool isContiguous() const
True if the localIds() are contiguous.
ItemIndexArrayView(const Int32ConstArrayView local_ids)
Constructs a view from the local IDs local_ids.
ItemIndexArrayView subView(Integer abegin, Integer asize) const
Sub-view starting from element abegin and containing asize elements.
Int32 size() const
Number of elements in the vector.
ItemIndexArrayView()=default
Constructs an empty view.
Int32ConstArrayView localIds() const
Array of local IDs of entities.
Int32 operator[](Integer index) const
Accesses the i-th element of the vector.
@ F_Contiguous
The local IDs are contiguous.
View over the container of a list of ItemLocalId.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
std::int32_t Int32
Signed integer type of 32 bits.