Arcane  v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
HashTable.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2023 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/* HashTable.cc (C) 2000-2023 */
9/* */
10/* Table de hachage. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/HashTable.h"
15#include "arcane/utils/HashTableMap.h"
16#include "arcane/utils/HashTableSet.h"
17#include "arcane/utils/Iostream.h"
18#include "arcane/utils/FatalErrorException.h"
19
20#include <exception>
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
32: public std::exception
33{
34 public:
35
36 virtual const char* what() const ARCANE_NOEXCEPT
37 {
38 return "HashTable::throwNotFound()";
39 }
40};
41
42/*---------------------------------------------------------------------------*/
43/*---------------------------------------------------------------------------*/
44
45void HashTableBase::
46_throwNotFound() const
47{
48 cerr << "** FATAL: HashTable:_throwNotFound()\n";
49 arcaneDebugPause("HashTableBase::throwNotFound()");
50 ARCANE_FATAL("key not found");
51}
52
53/*---------------------------------------------------------------------------*/
54/*---------------------------------------------------------------------------*/
55
57nearestPrimeNumber(Integer n)
58{
59 // Nouvelle liste avec plus d'éléments pour réduire l'usage
60 // mémoire
61 static Integer PRIME_NUMBER[] = {
62 53l,
63 97l,
64 193l,
65 389l,
66 769l,
67 1009l,
68 1213l,
69 1459l,
70 1753l,
71 2111l,
72 2539l,
73 3049l,
74 3659l,
75 4391l,
76 5273l,
77 6329l,
78 7603l,
79 9127l,
80 10957l,
81 13151l,
82 15787l,
83 18947l,
84 22739l,
85 27299l,
86 32771l,
87 39341l,
88 47221l,
89 56671l,
90 68023l,
91 81629l,
92 97961l,
93 117563l,
94 141079l,
95 169307l,
96 203173l,
97 243809l,
98 292573l,
99 351097l,
100 421331l,
101 505601l,
102 606731l,
103 728087l,
104 873707l,
105 1048507l,
106 1258211l,
107 1509857l,
108 1811837l,
109 2174243l,
110 2609107l,
111 3145739l,
112 3757147l,
113 4508597l,
114 5410331l,
115 6492403l,
116 7790897l,
117 9349079l,
118 11218903l,
119 13462693l,
120 16155239l,
121 19386313l,
122 23263577l,
123 27916297l,
124 //TODO AJOUTER ICI d'autres valeurs
125 50331653l,
126 100663319l,
127 201326611l,
128 402653189l,
129 805306457l,
130 1610612741l
131 };
132 int nb = sizeof(PRIME_NUMBER) / sizeof(Integer);
133
134 for (Integer i = 0; i < nb; ++i)
135 if (PRIME_NUMBER[i] >= n) {
136 return PRIME_NUMBER[i];
137 }
138 return n;
139}
140
141/*---------------------------------------------------------------------------*/
142/*---------------------------------------------------------------------------*/
143
144} // namespace Arcane
145
146/*---------------------------------------------------------------------------*/
147/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Integer nearestPrimeNumber(Integer n)
Retourne le nombre premier le plus proche de n par excès. Le nombre premier le plus proche et supérie...
Definition HashTable.cc:57
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
void arcaneDebugPause(const char *msg)
Passe en mode pause ou lance une erreur fatale.
Definition Misc.cc:220