Arcane  v3.16.0.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
ItemInternalVectorView.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 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/* ItemInternalVectorView.h (C) 2000-2024 */
9/* */
10/* Vue sur un vecteur (tableau indirect) d'entités. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ITEMINTERNALVECTORVIEW_H
13#define ARCANE_CORE_ITEMINTERNALVECTORVIEW_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/ArrayView.h"
19#include "arcane/core/ItemSharedInfo.h"
20#include "arcane/core/ItemIndexedListView.h"
21
22#include <iterator>
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27namespace Arcane
28{
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32/*!
33 * \internal
34 * \brief Iterateur d'un ItemInternalVectorView.
35 * \deprecated Utiliser un itérateur à partir d'un ItemVectorView.
36 */
37class ItemInternalVectorViewConstIterator
38{
39 friend class ItemInternalVectorView;
40 template<int Extent> friend class ItemConnectedListView;
41 typedef ItemInternal* ItemInternalPtr;
42
43 private:
44
45 ItemInternalVectorViewConstIterator(const ItemInternalPtr* items,
46 const Int32* ARCANE_RESTRICT local_ids,
47 Integer index,Int32 local_id_offset)
48 : m_items(items), m_local_ids(local_ids), m_index(index), m_local_id_offset(local_id_offset){}
49
50 public:
51
52 typedef ItemInternalVectorViewConstIterator ThatClass;
53
54 public:
55 typedef std::random_access_iterator_tag iterator_category;
56 //! Type indexant le tableau
57 typedef const ItemInternalPtr* pointer;
58 //! Type indexant le tableau
59 typedef const ItemInternalPtr& reference;
60 //! Type indexant le tableau
61 typedef ItemInternalPtr value_type;
62 //! Type indexant le tableau
64 //! Type d'une distance entre itérateur éléments du tableau
66 public:
67 value_type operator*() const { return m_items[ m_local_id_offset + m_local_ids[m_index] ]; }
68 value_type operator->() const { return m_items[ m_local_id_offset + m_local_ids[m_index] ]; }
69 ThatClass& operator++() { ++m_index; return (*this); }
70 ThatClass& operator--() { --m_index; return (*this); }
71 void operator+=(difference_type v) { m_index += v; }
72 void operator-=(difference_type v) { m_index -= v; }
73 friend Integer operator-(const ThatClass& a,const ThatClass& b)
74 {
75 return a.m_index - b.m_index;
76 }
77 friend ThatClass operator-(const ThatClass& a,difference_type v)
78 {
79 Integer index = a.m_index - v;
80 return ThatClass(a.m_items,a.m_local_ids,index,a.m_local_id_offset);
81 }
82 friend ThatClass operator+(const ThatClass& a,difference_type v)
83 {
84 Integer index = a.m_index + v;
85 return ThatClass(a.m_items,a.m_local_ids,index,a.m_local_id_offset);
86 }
87 friend bool operator<(const ThatClass& lhs,const ThatClass& rhs)
88 {
89 return lhs.m_index<=rhs.m_index;
90 }
91 friend bool operator==(const ThatClass& lhs,const ThatClass& rhs)
92 {
93 // TODO: regarder si cela ne pose pas de problemes de performance
94 // de faire ces trois comparaions. Si c'est le cas on peut
95 // faire uniquement la dernière.
96 return lhs.m_items==rhs.m_items && lhs.m_local_ids==rhs.m_local_ids && lhs.m_index==rhs.m_index;
97 }
98 friend bool operator!=(const ThatClass& lhs,const ThatClass& rhs)
99 {
100 return !(lhs==rhs);
101 }
102
103 private:
104
105 const ItemInternalPtr* m_items;
106 const Int32* ARCANE_RESTRICT m_local_ids;
107 Int32 m_index;
108 Int32 m_local_id_offset = 0;
109};
110
111/*---------------------------------------------------------------------------*/
112/*---------------------------------------------------------------------------*/
113/*!
114 * \internal
115 * \brief Vue interne sur un tableau d'entités.
116 *
117 * Celle classe n'est utile que pour construire des listes d'entités utilisées
118 * en interne de %Arcane. La version utilisateur de cette classe est
119 * ItemVectorView.
120 *
121 * \sa ItemVectorView
122 */
123class ARCANE_CORE_EXPORT ItemInternalVectorView
124{
125 public:
126
127 friend class ItemVectorView;
128 friend class ItemInternalConnectivityList;
129 friend class ItemBase;
130 friend class ItemEnumeratorBase;
131 friend class SimdItemEnumeratorBase;
132 friend class ItemInternalEnumerator;
133 template<int Extent> friend class ItemConnectedListView;
134 friend ItemInternal;
135 template <typename T> friend class ItemEnumeratorBaseT;
136 using const_iterator = ItemInternalVectorViewConstIterator;
137
138 public:
139
140 ItemInternalVectorView() = default;
141
142 private:
143
144 ItemInternalVectorView(ItemSharedInfo* si, Int32ConstArrayView local_ids, Int32 local_id_offset)
145 : m_local_ids(local_ids)
146 , m_shared_info(si)
147 , m_local_id_offset(local_id_offset)
148 {
149 ARCANE_ASSERT(_isValid(), ("Bad ItemInternalVectorView"));
150 }
151
152#if 0
153 ItemInternalVectorView(ItemSharedInfo* si, const Int32* local_ids, Integer count, Int32 local_id_offset)
154 : m_local_ids(count, local_ids)
155 , m_shared_info(si)
156 , m_local_id_offset(local_id_offset)
157 {
158 ARCANE_ASSERT(_isValid(), ("Bad ItemInternalVectorView"));
159 }
160#endif
161
162 ItemInternalVectorView(ItemSharedInfo* si, const impl::ItemLocalIdListContainerView& local_ids)
163 : m_local_ids(local_ids._idsWithoutOffset())
164 , m_shared_info(si)
165 , m_local_id_offset(local_ids.m_local_id_offset)
166 {
167 ARCANE_ASSERT(_isValid(), ("Bad ItemInternalVectorView"));
168 }
169
170 ItemInternalVectorView(const impl::ItemIndexedListView<DynExtent>& view)
171 : m_local_ids(view.constLocalIds())
172 , m_shared_info(view.m_shared_info)
173 , m_local_id_offset(view.m_local_id_offset)
174 {}
175
176 public:
177
178 //! Nombre d'éléments du vecteur
179 Integer size() const { return m_local_ids.size(); }
180
181 // TODO: à supprimer
182 //! Tableau des numéros locaux des entités
183 Int32ConstArrayView localIds() const { return m_local_ids; }
184
185 public:
186
187 /*!
188 * \brief Accède au \a i-ème élément du vecteur.
189 *
190 * Cette méthode est obsolète. Il faut construire un 'ItemVectorView' à la place
191 * et utiliser l'opérateur 'operator[]' associé.
192 */
193 ARCANE_DEPRECATED_REASON("Y2022: Use ItemVectorView::operator[] instead")
194 ItemInternal* operator[](Integer index) const { return m_shared_info->m_items_internal[m_local_ids[index]]; }
195
196 //! Tableau des entités
197 ARCANE_DEPRECATED_REASON("Y2022: Do not use this method")
198 ItemInternalArrayView items() const { return m_shared_info->m_items_internal; }
199
200 ARCANE_DEPRECATED_REASON("Y2022: Use ItemVectorView to iterate")
201 const_iterator begin() const
202 {
203 return const_iterator(_items().data(), m_local_ids.data(), 0, m_local_id_offset);
204 }
205
206 ARCANE_DEPRECATED_REASON("Y2022: Use ItemVectorView to iterate")
207 const_iterator end() const
208 {
209 return const_iterator(_items().data(), m_local_ids.data(), this->size(), m_local_id_offset);
210 }
211
212 protected:
213
214 Int32 localIdOffset() const { return m_local_id_offset; }
215
216 protected:
217
218 Int32ConstArrayView m_local_ids;
219 ItemSharedInfo* m_shared_info = ItemSharedInfo::nullInstance();
220 Int32 m_local_id_offset = 0;
221
222 private:
223
224 bool _isValid();
225 ItemInternalArrayView _items() const { return m_shared_info->m_items_internal; }
226};
227
228/*---------------------------------------------------------------------------*/
229/*---------------------------------------------------------------------------*/
230
231} // End namespace Arcane
232
233/*---------------------------------------------------------------------------*/
234/*---------------------------------------------------------------------------*/
235
236#endif
Déclarations de types sur les entités.
const ItemInternalPtr * pointer
Type indexant le tableau.
ItemInternalPtr value_type
Type indexant le tableau.
Integer difference_type
Type d'une distance entre itérateur éléments du tableau.
const ItemInternalPtr & reference
Type indexant le tableau.
Int32ConstArrayView localIds() const
Tableau des numéros locaux des entités.
ItemInternalArrayView items() const
Tableau des entités.
Integer size() const
Nombre d'éléments du vecteur.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.
ConstArrayView< Int32 > Int32ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:569
std::int32_t Int32
Type entier signé sur 32 bits.