Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ItemPairEnumerator.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/* ItemPairEnumerator.h (C) 2000-2025 */
9/* */
10/* Enumerator over an array of arrays of mesh entities. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ITEMPAIRENUMERATOR_H
13#define ARCANE_CORE_ITEMPAIRENUMERATOR_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/core/Item.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29class ItemInternal;
30class ItemItemArray;
31
32/*---------------------------------------------------------------------------*/
33/*---------------------------------------------------------------------------*/
34
38class ARCANE_CORE_EXPORT ItemPairEnumerator
39{
40 public:
41
42 typedef ItemInternal* ItemInternalPtr;
43
44 public:
45
46 ItemPairEnumerator(const ItemPairGroup& array);
47 ItemPairEnumerator() = default;
48
49 public:
50
51 inline void operator++()
52 {
53 ++m_current;
54 }
55 inline bool hasNext() const
56 {
57 return m_current < m_end;
58 }
59 inline Int32 itemLocalId() const
60 {
61 return m_items_local_id[m_current];
62 }
63 inline Int32 index() const
64 {
65 return m_current;
66 }
67 inline ItemEnumerator subItems() const
68 {
69 return { m_sub_items_shared_info, _ids() };
70 }
71 inline Item operator*() const
72 {
73 return Item(m_items_local_id[m_current], m_items_shared_info);
74 }
75 inline Integer nbSubItem() const
76 {
77 return static_cast<Int32>(m_indexes[m_current + 1] - m_indexes[m_current]);
78 }
79
81 operator ItemLocalId() const { return ItemLocalId{ itemLocalId() }; }
82
83 protected:
84
85 Int32 m_current = 0;
86 Int32 m_end = 0;
87 Int64ConstArrayView m_indexes;
88 Int32ConstArrayView m_items_local_id;
89 Span<const Int32> m_sub_items_local_id;
90 ItemSharedInfo* m_items_shared_info = ItemSharedInfo::nullInstance();
91 ItemSharedInfo* m_sub_items_shared_info = ItemSharedInfo::nullInstance();
92
93 protected:
94
95 Item _currentItem() const
96 {
97 return Item(m_items_local_id[m_current], m_items_shared_info);
98 }
99 ConstArrayView<Int32> _ids() const
100 {
101 return ConstArrayView<Int32>(nbSubItem(), m_sub_items_local_id.data() + m_indexes[m_current]);
102 }
103};
104
105/*---------------------------------------------------------------------------*/
106/*---------------------------------------------------------------------------*/
107
112template <typename ItemType>
113class ItemPairEnumeratorSubT
114: public ItemPairEnumerator
115{
116 public:
117
118 ItemPairEnumeratorSubT(const ItemPairGroup& array)
119 : ItemPairEnumerator(array)
120 {
121 }
122
123 public:
124
125 inline ItemType operator*() const
126 {
127 return ItemType(this->_currentItem());
128 }
130 operator ItemLocalIdT<ItemType>() const { return ItemLocalIdT<ItemType>{ this->itemLocalId() }; }
131};
132
133/*---------------------------------------------------------------------------*/
134/*---------------------------------------------------------------------------*/
135
140template <typename ItemType, typename SubItemType>
141class ItemPairEnumeratorT
142: public ItemPairEnumeratorSubT<ItemType>
143{
144 using BaseClass = ItemPairEnumeratorSubT<ItemType>;
145
146 public:
147
148 ItemPairEnumeratorT(const ItemPairGroupT<ItemType, SubItemType>& array)
149 : ItemPairEnumeratorSubT<ItemType>(array)
150 {
151 }
152
153 ItemEnumeratorT<SubItemType> subItems() const
154 {
155 return { this->m_sub_items_shared_info, this->_ids() };
156 }
157};
158
159/*---------------------------------------------------------------------------*/
160/*---------------------------------------------------------------------------*/
161
162} // End namespace Arcane
163
164/*---------------------------------------------------------------------------*/
165/*---------------------------------------------------------------------------*/
166
167#endif
Types and macros for iterating over mesh entities.
Enumerator over a typed list of entities of type ItemType.
Enumerator over a list of entities.
Internal structure of a mesh entity.
Index of an ItemType entity in a variable.
Definition ItemLocalId.h:92
Index of an Item in a variable.
Definition ItemLocalId.h:42
Reference to a group of a given kind.
Table of entity lists.
Internal shared structure of a mesh entity.
Base class for a mesh element.
Definition Item.h:84
constexpr __host__ __device__ pointer data() const noexcept
Pointer to the start of the view.
Definition Span.h:539
View of an array of elements of type T.
Definition Span.h:635
-- 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
ConstArrayView< Int64 > Int64ConstArrayView
C equivalent of a 1D array of 64-bit integers.
Definition UtilsTypes.h:480
std::int32_t Int32
Signed integer type of 32 bits.