Arcane  v3.15.3.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
HashSuite.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/* HashSuite.h (C) 2000-2025 */
9/* */
10/* Fonction de hachage d'une suite de valeur. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_HASHSUITE_H
13#define ARCANE_UTILS_HASHSUITE_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/HashFunction.h"
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28/*!
29 * \internal
30 * \brief Classe permettant de calculer un hash de manière itératif.
31 * \warning L'ordre dans lequel les valeurs sont données via la méthode add() est important.
32 */
33
35{
36 public:
37
38 /*!
39 * \brief Méthode permettant d'ajouter une valeur dans le calcul du hash.
40 * \warning L'ordre dans lequel les valeurs sont données via la méthode
41 * add() est important.
42 * \param value La valeur à ajouter.
43 */
44 template <class T>
45 void add(T value)
46 {
47 const UInt64 next_hash = static_cast<UInt64>(IntegerHashFunctionT<T>::hashfunc(value));
48 m_hash ^= next_hash + 0x9e3779b9 + (m_hash << 6) + (m_hash >> 2);
49 }
50
51 /*!
52 * \brief Méthode permettant de récupérer le hash calculé à partir de
53 * toutes les valeurs passées à la méthode add().
54 * \return Le hash.
55 */
56 Int64 hash() const
57 {
58 return static_cast<Int64>(m_hash);
59 }
60
61 private:
62
63 UInt64 m_hash{0};
64};
65
66/*---------------------------------------------------------------------------*/
67/*---------------------------------------------------------------------------*/
68
69} // End namespace Arcane
70
71/*---------------------------------------------------------------------------*/
72/*---------------------------------------------------------------------------*/
73
74#endif
void add(T value)
Méthode permettant d'ajouter une valeur dans le calcul du hash.
Definition HashSuite.h:45
Int64 hash() const
Méthode permettant de récupérer le hash calculé à partir de toutes les valeurs passées à la méthode a...
Definition HashSuite.h:56
Référence à une instance.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-