Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
VariableCollection.cc
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/* VariableCollection.cc (C) 2000-2019 */
9/* */
10/* Base class of a mesh element. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/VariableCollection.h"
15
16/*---------------------------------------------------------------------------*/
17/*---------------------------------------------------------------------------*/
18
19namespace Arcane
20{
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25VariableCollection::
26VariableCollection()
27: m_p(new Impl())
28{
29}
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
34VariableCollection::
35VariableCollection(const Enumerator& rhs)
36: m_p(new Impl())
37{
38 _values().copy(rhs.m_collection);
39}
40
41/*---------------------------------------------------------------------------*/
42/*---------------------------------------------------------------------------*/
43
44void VariableCollection::
45sortByName(bool is_ascendent)
46{
47 Array<IVariable*>& v = _values();
48 auto sort_func = [](IVariable* v1, IVariable* v2) {
49 return v1->fullName() < v2->fullName();
50 };
51
52 if (is_ascendent)
53 std::sort(v.begin(), v.end(), sort_func);
54 else
55 std::sort(v.rbegin(), v.rend(), sort_func);
56}
57
58/*---------------------------------------------------------------------------*/
59/*---------------------------------------------------------------------------*/
60
61/*---------------------------------------------------------------------------*/
62/*---------------------------------------------------------------------------*/
63
64VariableCollectionEnumerator::
65VariableCollectionEnumerator(const VariableCollection& col)
66: m_index(-1)
67, m_collection(col._values())
68{
69 m_count = m_collection.size();
70}
71
72/*---------------------------------------------------------------------------*/
73/*---------------------------------------------------------------------------*/
74
75} // End namespace Arcane
76
77/*---------------------------------------------------------------------------*/
78/*---------------------------------------------------------------------------*/
Base class for 1D data vectors.
reverse_iterator rbegin()
Reverse iterator over the first element of the array.
iterator begin()
Iterator over the first element of the array.
reverse_iterator rend()
Reverse iterator over the first element after the end of the array.
iterator end()
Iterator over the first element after the end of the array.
Interface of a variable.
Definition IVariable.h:40
virtual String fullName() const =0
Full variable name (with family prefix).
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --