Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
ItemGroupRangeIterator.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/* ItemGroupRangeIterator.h (C) 2000-2025 */
9/* */
10/* Iteration range over the entities of a mesh group. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ITEMGROUPRANGEITERATOR_H
13#define ARCANE_CORE_ITEMGROUPRANGEITERATOR_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/core/ItemInfoListView.h"
18#include "arcane/core/Item.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29/*!
30 * \brief Iterator over the elements of a group.
31 */
32class ARCANE_CORE_EXPORT ItemGroupRangeIterator
33{
34 public:
35
36 typedef ItemInternal* ItemPtr;
37 typedef ItemPtr* Iterator;
38
39 ItemGroupRangeIterator(const ItemGroup& group);
40 ItemGroupRangeIterator();
41
42 public:
43
44 inline void operator++()
45 {
46 ++m_current;
47 }
48 inline bool hasNext() const
49 {
50 return m_current < m_end;
51 }
52 inline Integer itemLocalId() const
53 {
54 return m_items_local_ids[m_current];
55 }
56 inline Integer index() const
57 {
58 return m_current;
59 }
60 inline eItemKind kind() const
61 {
62 return m_kind;
63 }
64
65 protected:
66
67 eItemKind m_kind;
68 Integer m_current;
69 Integer m_end;
70 const Int32* ARCANE_RESTRICT m_items_local_ids;
71 ItemInfoListView m_items;
72};
73
74/*---------------------------------------------------------------------------*/
75/*---------------------------------------------------------------------------*/
76
77/*!
78 * \brief Iteration range over a group of mesh entities.
79 */
80template <typename T>
81class ItemGroupRangeIteratorT
82: public ItemGroupRangeIterator
83{
84 public:
85
86 inline ItemGroupRangeIteratorT(const ItemGroup& group)
87 : ItemGroupRangeIterator(group)
88 {
89 }
90 inline ItemGroupRangeIteratorT()
91 : ItemGroupRangeIterator()
92 {
93 }
94
95 public:
96
97 T operator*() const
98 {
99 return T(m_items[m_items_local_ids[m_current]]);
100 }
101};
102
103/*---------------------------------------------------------------------------*/
104/*---------------------------------------------------------------------------*/
105
106} // namespace Arcane
107
108/*---------------------------------------------------------------------------*/
109/*---------------------------------------------------------------------------*/
110
111#endif
Mesh entity group.
Definition ItemGroup.h:51
View of a list to obtain information about entities.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
eItemKind
Mesh entity type.
std::int32_t Int32
Signed integer type of 32 bits.