Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ItemArrayEnumerator.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/* ItemArrayEnumerator.h (C) 2000-2025 */
9/* */
10/* Enumerator over an array of mesh entities. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ITEMARRAYENUMERATOR_H
13#define ARCANE_CORE_ITEMARRAYENUMERATOR_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/core/Item.h"
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
31class ARCANE_CORE_EXPORT ItemArrayEnumerator
32{
33 public:
34
35 typedef ItemInternal* ItemPtr;
36 typedef ItemPtr* Iterator;
37
38 public:
39
40 ItemArrayEnumerator(const Int32ConstArrayView ids, const ItemInternalList& items_internal)
41 : m_current(0)
42 , m_end(ids.size())
43 , m_items_local_id(ids.data())
44 , m_items_internal(items_internal.data())
45 {
46 }
47 ItemArrayEnumerator(const Int32* ids, Integer nb_item, const ItemPtr* items_internal)
48 : m_current(0)
49 , m_end(nb_item)
50 , m_items_local_id(ids)
51 , m_items_internal(items_internal)
52 {
53 }
54
55 public:
56
57 inline void operator++()
58 {
59 ++m_current;
60 }
61 inline bool hasNext() const
62 {
63 return m_current < m_end;
64 }
65 inline Integer itemLocalId() const
66 {
67 return m_items_local_id[m_current];
68 }
69 inline Integer index() const
70 {
71 return m_current;
72 }
73 inline Item operator*() const
74 {
75 return Item(m_items_internal, m_items_local_id[m_current]);
76 }
77
78 protected:
79
80 Integer m_current;
81 Integer m_end;
82 const Int32* ARCANE_RESTRICT m_items_local_id;
83 const ItemPtr* m_items_internal;
84};
85
86/*---------------------------------------------------------------------------*/
87/*---------------------------------------------------------------------------*/
88
92template <typename ItemType>
93class ItemArrayEnumeratorT
94: public ItemArrayEnumerator
95{
96 public:
97
98 ItemArrayEnumeratorT(const Int32ConstArrayView ids, const ItemInternalList& items_internal)
99 : ItemArrayEnumerator(ids, items_internal)
100 {
101 }
102 ItemArrayEnumeratorT(const Int32* ids, Integer nb_item, const ItemPtr* items_internal)
103 : ItemArrayEnumerator(ids, nb_item, items_internal)
104 {
105 }
106 inline ItemType operator*() const
107 {
108 return ItemType(m_items_internal, m_items_local_id[m_current]);
109 }
110};
111
112/*---------------------------------------------------------------------------*/
113/*---------------------------------------------------------------------------*/
114
115} // namespace Arcane
116
117/*---------------------------------------------------------------------------*/
118/*---------------------------------------------------------------------------*/
119
120#endif
constexpr const_pointer data() const noexcept
Pointer to the allocated memory.
constexpr Integer size() const noexcept
Number of elements in the array.
Internal structure of a mesh entity.
Base class for a mesh element.
Definition Item.h:84
-- 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< ItemInternal * > ItemInternalList
Type of the internal list of entities.
Definition ItemTypes.h:466
std::int32_t Int32
Signed integer type of 32 bits.