Arcane  v3.16.4.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
ItemInternalSortFunction.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 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/* ItemInternalSortFunction.h (C) 2000-2025 */
9/* */
10/* Fonction de tri des entités. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ITEMINTERNALSORTFUNCTION_H
13#define ARCANE_CORE_ITEMINTERNALSORTFUNCTION_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/String.h"
18#include "arcane/IItemInternalSortFunction.h"
19
20#include <algorithm>
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30/*!
31 * \ingroup Mesh
32 * \brief Interface d'une fonction de tri des entités.
33 *
34 * Cette classe est utilisée pour trier des entités.
35 * Il faut spécifier comme paramètre template un functor
36 * ayant le prototype suivant:
37 * \code
38 * bool operator()(const ItemInternal* item1,const ItemInternal* item2) const
39 * \endcode
40 * et qui retourne \a true si \a item1 est avant \a item2.
41 */
42template <typename SortFunction>
43class ItemInternalSortFunction
45{
46 public:
47
48 explicit ItemInternalSortFunction(const String& name)
49 : m_name(name)
50 {}
51
52 public:
53
54 const String& name() const override { return m_name; }
55
56 public:
57
58 /*!
59 * \brief Trie les entités du tableau \a items.
60 */
61 void sortItems(ItemInternalMutableArrayView items) override
62 {
63 std::sort(std::begin(items), std::end(items), SortFunction());
64 }
65
66 private:
67
68 String m_name;
69};
70
71/*---------------------------------------------------------------------------*/
72/*---------------------------------------------------------------------------*/
73
74} // namespace Arcane
75
76/*---------------------------------------------------------------------------*/
77/*---------------------------------------------------------------------------*/
78
79#endif
Interface d'une fonction de tri des entités.
void sortItems(ItemInternalMutableArrayView items) override
Trie les entités du tableau items.
const String & name() const override
Nom de la fonction de tri.
Chaîne de caractères unicode.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-