Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
HashTable.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/* HashTable.cc (C) 2000-2023 */
9/* */
10/* Hash table. */
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
58{
59 // New list with more elements to reduce memory usage
60 static Integer PRIME_NUMBER[] = {
61 53l,
62 97l,
63 193l,
64 389l,
65 769l,
66 1009l,
67 1213l,
68 1459l,
69 1753l,
70 2111l,
71 2539l,
72 3049l,
73 3659l,
74 4391l,
75 5273l,
76 6329l,
77 7603l,
78 9127l,
79 10957l,
80 13151l,
81 15787l,
82 18947l,
83 22739l,
84 27299l,
85 32771l,
86 39341l,
87 47221l,
88 56671l,
89 68023l,
90 81629l,
91 97961l,
92 117563l,
93 141079l,
94 169307l,
95 203173l,
96 243809l,
97 292573l,
98 351097l,
99 421331l,
100 505601l,
101 606731l,
102 728087l,
103 873707l,
104 1048507l,
105 1258211l,
106 1509857l,
107 1811837l,
108 2174243l,
109 2609107l,
110 3145739l,
111 3757147l,
112 4508597l,
113 5410331l,
114 6492403l,
115 7790897l,
116 9349079l,
117 11218903l,
118 13462693l,
119 16155239l,
120 19386313l,
121 23263577l,
122 27916297l,
123 //TODO ADD OTHER VALUES HERE
124 50331653l,
125 100663319l,
126 201326611l,
127 402653189l,
128 805306457l,
129 1610612741l
130 };
131 int nb = sizeof(PRIME_NUMBER) / sizeof(Integer);
132
133 for (Integer i = 0; i < nb; ++i)
134 if (PRIME_NUMBER[i] >= n) {
135 return PRIME_NUMBER[i];
136 }
137 return n;
138}
139
140/*---------------------------------------------------------------------------*/
141/*---------------------------------------------------------------------------*/
142
143} // namespace Arcane
144
145/*---------------------------------------------------------------------------*/
146/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Integer nearestPrimeNumber(Integer n)
Returns the nearest prime number greater than n. The nearest prime number greater than n is returned ...
Definition HashTable.cc:57
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
void arcaneDebugPause(const char *msg)
Enters pause mode or throws a fatal error.
Definition Misc.cc:122