OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
c_hash_table.cpp
Go to the documentation of this file.
1//Copyright> OpenRadioss
2//Copyright> Copyright (C) 1986-2025 Altair Engineering Inc.
3//Copyright>
4//Copyright> This program is free software: you can redistribute it and/or modify
5//Copyright> it under the terms of the GNU Affero General Public License as published by
6//Copyright> the Free Software Foundation, either version 3 of the License, or
7//Copyright> (at your option) any later version.
8//Copyright>
9//Copyright> This program is distributed in the hope that it will be useful,
10//Copyright> but WITHOUT ANY WARRANTY; without even the implied warranty of
11//Copyright> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12//Copyright> GNU Affero General Public License for more details.
13//Copyright>
14//Copyright> You should have received a copy of the GNU Affero General Public License
15//Copyright> along with this program. If not, see <https://www.gnu.org/licenses/>.
16//Copyright>
17//Copyright>
18//Copyright> Commercial Alternative: Altair Radioss Software
19//Copyright>
20//Copyright> As an alternative to this open-source version, Altair also offers Altair Radioss
21//Copyright> software under a commercial license. Contact Altair to discuss further if the
22//Copyright> commercial version may interest you: https://www.altair.com/radioss/.
23#include <unordered_map>
24#include <iostream>
25#include <vector>
26
27#define _FCALL
28
29
30// global vector of hash table
31std::vector<std::unordered_map<int,int>> umaps;
32
33extern "C" {
34 void c_new_hash_(int * map_id,int * count)
35 {
36 umaps.push_back(std::unordered_map<int,int>());
37// c++11 add reserve of size count here
38 (*map_id) = umaps.size()-1;
39 }
40 void c_delete_hash_(int *map)
41 {
42 if(*map >= umaps.size() || *map < 0)
43 {
44
45 } else
46 {
47 umaps[*map].clear();
48 }
49 }
50
51// should be called with val being an invalid value
52 void c_hash_find_(int * map_id, int * key, int * val )
53 {
54 if(*map_id >= 0 && *map_id < umaps.size())
55 {
56 int s = umaps[*map_id].size();
57 int keyloc = *key;
58 std::unordered_map<int,int>::const_iterator got = umaps[*map_id].find(keyloc);
59 if( got == umaps[*map_id].end() )
60 {
61 // not found, val is not changed
62 } else
63 {
64 (*val) = got->second;
65 }
66 }
67 }
68 void c_hash_insert_(int * map_id, int * key, int * val )
69 {
70 int ival = *val;
71 int imap_id = *map_id;
72 int ikey = *key;
73 if(*map_id >= 0 && *map_id < umaps.size())
74 {
75 std::unordered_map<int,int>::const_iterator got = umaps[imap_id].find(ikey);
76 if( got == umaps[imap_id].end() )
77 {
78 umaps[imap_id][ikey] = ival;
79 } else
80 {
81
82 }
83 }
84 }
85 void c_hash_replace_(int * map_id, int * key, int * val )
86 {
87 if(*map_id >= 0 && *map_id < umaps.size())
88 {
89 std::unordered_map<int,int>::const_iterator got = umaps[*map_id].find(*key);
90 umaps[*map_id][*key] = *val;
91 }
92 }
93
94// Fortran 2 C porting
95 void _FCALL C_NEW_HASH(int * map, int * count)
96 {
97 c_new_hash_(map,count);
98 }
99 void c_new_hash__(int * map, int * count)
100 {
101 c_new_hash_(map,count);
102 }
103 void c_new_hash(int * map,int * count)
104 {
105 c_new_hash_(map,count);
106 }
107
108 void _FCALL C_DELETE_HASH(int * map)
109 {
110 c_delete_hash_(map);
111 }
112 void c_delete_hash__(int * map)
113 {
114 c_delete_hash_(map);
115 }
116 void c_delete_hash(int * map)
117 {
118 c_delete_hash_(map);
119 }
120
121 void _FCALL C_HASH_FIND(int* map, int * key, int * val )
122 {
123 c_hash_find_(map, key, val);
124 }
125 void c_hash_find__(int* map, int * key, int * val )
126 {
127 c_hash_find_(map, key, val);
128 }
129 void c_hash_find(int* map, int * key, int * val )
130 {
131 c_hash_find_(map, key, val);
132 }
133
134 void _FCALL C_HASH_INSERT(int* map, int * key, int * val)
135 {
136 c_hash_insert_(map, key, val);
137 }
138 void c_hash_insert__(int* map, int * key, int * val)
139 {
140 c_hash_insert_(map, key, val);
141 }
142 void c_hash_insert(int* map, int * key, int * val)
143 {
144 c_hash_insert_(map, key, val);
145 }
146
147 void _FCALL C_HASH_REPLACE(int* map, int * key, int * val)
148 {
149 c_hash_replace_(map, key, val);
150 }
151 void c_hash_replace__(int* map, int * key, int * val)
152 {
153 c_hash_replace_(map, key, val);
154 }
155 void c_hash_replace(int* map, int * key, int * val)
156 {
157 c_hash_replace_(map, key, val);
158 }
159}
void _FCALL C_HASH_REPLACE(int *map, int *key, int *val)
void c_hash_insert__(int *map, int *key, int *val)
void c_hash_find_(int *map_id, int *key, int *val)
void c_new_hash(int *map, int *count)
void c_hash_replace_(int *map_id, int *key, int *val)
void c_delete_hash_(int *map)
void _FCALL C_HASH_INSERT(int *map, int *key, int *val)
void c_delete_hash(int *map)
void c_hash_find(int *map, int *key, int *val)
void c_hash_replace__(int *map, int *key, int *val)
void c_hash_insert_(int *map_id, int *key, int *val)
void _FCALL C_DELETE_HASH(int *map)
void _FCALL C_NEW_HASH(int *map, int *count)
void c_hash_find__(int *map, int *key, int *val)
void c_new_hash_(int *map_id, int *count)
void c_hash_insert(int *map, int *key, int *val)
void c_hash_replace(int *map, int *key, int *val)
void c_delete_hash__(int *map)
void c_new_hash__(int *map, int *count)
void _FCALL C_HASH_FIND(int *map, int *key, int *val)
std::vector< std::unordered_map< int, int > > umaps
end[inform, rinform, sol, inst, schur, redrhs, pivnul_list, sym_perm, uns_perm, icntl, cntl, colsca_out, rowsca_out, keep_out, dkeep_out]
Definition dmumps.m:40
#define _FCALL