mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 08:38:23 +01:00
replase master_isotope_hash_table with master_isotope_map
This commit is contained in:
parent
c01c8d66bf
commit
52e0622596
@ -904,16 +904,11 @@ void Phreeqc::init(void)
|
|||||||
remove_unstable_phases = FALSE;
|
remove_unstable_phases = FALSE;
|
||||||
// auto screen_string;
|
// auto screen_string;
|
||||||
spread_length = 10;
|
spread_length = 10;
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
/*
|
|
||||||
* Hash definitions
|
|
||||||
*/
|
|
||||||
master_isotope_hash_table = NULL;
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
* ISOTOPES
|
* ISOTOPES
|
||||||
* ---------------------------------------------------------------------- */
|
* ---------------------------------------------------------------------- */
|
||||||
initial_solution_isotopes = FALSE;
|
initial_solution_isotopes = FALSE;
|
||||||
calculate_value_hash_table = NULL;
|
calculate_value_hash_table = NULL;
|
||||||
isotope_ratio_hash_table = 0;
|
isotope_ratio_hash_table = 0;
|
||||||
isotope_alpha_hash_table = 0;
|
isotope_alpha_hash_table = 0;
|
||||||
|
|
||||||
|
|||||||
@ -1665,7 +1665,7 @@ protected:
|
|||||||
std::map<std::string, struct species*> species_map;
|
std::map<std::string, struct species*> species_map;
|
||||||
std::map<std::string, struct phase*> phases_map;
|
std::map<std::string, struct phase*> phases_map;
|
||||||
std::map<std::string, struct logk*> logk_map;
|
std::map<std::string, struct logk*> logk_map;
|
||||||
HashTable *master_isotope_hash_table;
|
std::map<std::string, struct master_isotope*> master_isotope_map;
|
||||||
|
|
||||||
#if defined(PHREEQCI_GUI)
|
#if defined(PHREEQCI_GUI)
|
||||||
#include "../../phreeqci_gui.h"
|
#include "../../phreeqci_gui.h"
|
||||||
|
|||||||
56
isotopes.cpp
56
isotopes.cpp
@ -1325,25 +1325,19 @@ master_isotope_store(const char *name, int replace_if_found)
|
|||||||
*/
|
*/
|
||||||
int n;
|
int n;
|
||||||
struct master_isotope *master_isotope_ptr;
|
struct master_isotope *master_isotope_ptr;
|
||||||
ENTRY item, *found_item;
|
|
||||||
char token[MAX_LENGTH];
|
|
||||||
/*
|
/*
|
||||||
* Search list
|
* Search list
|
||||||
*/
|
*/
|
||||||
strcpy(token, name);
|
std::map<std::string, struct master_isotope*>::iterator mi_it =
|
||||||
|
master_isotope_map.find(name);
|
||||||
item.key = token;
|
if (mi_it != master_isotope_map.end() && replace_if_found == FALSE)
|
||||||
item.data = NULL;
|
|
||||||
found_item = hsearch_multi(master_isotope_hash_table, item, FIND);
|
|
||||||
|
|
||||||
if (found_item != NULL && replace_if_found == FALSE)
|
|
||||||
{
|
{
|
||||||
master_isotope_ptr = (struct master_isotope *) (found_item->data);
|
master_isotope_ptr = mi_it->second;
|
||||||
return (master_isotope_ptr);
|
return (master_isotope_ptr);
|
||||||
}
|
}
|
||||||
else if (found_item != NULL && replace_if_found == TRUE)
|
else if (mi_it != master_isotope_map.end() && replace_if_found == TRUE)
|
||||||
{
|
{
|
||||||
master_isotope_ptr = (struct master_isotope *) (found_item->data);
|
master_isotope_ptr = mi_it->second;
|
||||||
master_isotope_init(master_isotope_ptr);
|
master_isotope_init(master_isotope_ptr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1355,19 +1349,11 @@ master_isotope_store(const char *name, int replace_if_found)
|
|||||||
master_isotope_ptr = master_isotope[n];
|
master_isotope_ptr = master_isotope[n];
|
||||||
}
|
}
|
||||||
/* set name and z in pointer in master_isotope structure */
|
/* set name and z in pointer in master_isotope structure */
|
||||||
master_isotope_ptr->name = string_hsave(token);
|
master_isotope_ptr->name = string_hsave(name);
|
||||||
/*
|
/*
|
||||||
* Update hash table
|
* Update map
|
||||||
*/
|
*/
|
||||||
item.key = master_isotope_ptr->name;
|
master_isotope_map[name] = master_isotope_ptr;
|
||||||
item.data = (void *) master_isotope_ptr;
|
|
||||||
found_item = hsearch_multi(master_isotope_hash_table, item, ENTER);
|
|
||||||
if (found_item == NULL)
|
|
||||||
{
|
|
||||||
error_string = sformatf( "Hash table error in master_isotope_store.");
|
|
||||||
error_msg(error_string, CONTINUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (master_isotope_ptr);
|
return (master_isotope_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1381,11 +1367,7 @@ master_isotope_alloc(void)
|
|||||||
* return: pointer to a master_isotope structure
|
* return: pointer to a master_isotope structure
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
struct master_isotope *master_isotope_ptr;
|
struct master_isotope *master_isotope_ptr = new struct master_isotope;
|
||||||
master_isotope_ptr =
|
|
||||||
(struct master_isotope *) PHRQ_malloc(sizeof(struct master_isotope));
|
|
||||||
if (master_isotope_ptr == NULL)
|
|
||||||
malloc_error();
|
|
||||||
/*
|
/*
|
||||||
* set pointers in structure to NULL, variables to zero
|
* set pointers in structure to NULL, variables to zero
|
||||||
*/
|
*/
|
||||||
@ -1427,7 +1409,7 @@ master_isotope_search(const char *name)
|
|||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Function locates the string "name" in the hash table for master_isotope.
|
* Function locates the string "name" in the map for master_isotope.
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* name input, character string to be found in "master_isotope".
|
* name input, character string to be found in "master_isotope".
|
||||||
@ -1436,21 +1418,15 @@ master_isotope_search(const char *name)
|
|||||||
* pointer to master_isotope structure "master_isotope" where "name" can be found.
|
* pointer to master_isotope structure "master_isotope" where "name" can be found.
|
||||||
* or NULL if not found.
|
* or NULL if not found.
|
||||||
*/
|
*/
|
||||||
struct master_isotope *master_isotope_ptr;
|
struct master_isotope* master_isotope_ptr = NULL;
|
||||||
ENTRY item, *found_item;
|
|
||||||
char token[MAX_LENGTH];
|
|
||||||
/*
|
/*
|
||||||
* Search list
|
* Search list
|
||||||
*/
|
*/
|
||||||
strcpy(token, name);
|
std::map<std::string, struct master_isotope*>::iterator mi_it =
|
||||||
|
master_isotope_map.find(name);
|
||||||
item.key = token;
|
if (mi_it != master_isotope_map.end())
|
||||||
item.data = NULL;
|
|
||||||
found_item = hsearch_multi(master_isotope_hash_table, item, FIND);
|
|
||||||
|
|
||||||
if (found_item != NULL)
|
|
||||||
{
|
{
|
||||||
master_isotope_ptr = (struct master_isotope *) (found_item->data);
|
master_isotope_ptr = mi_it->second;
|
||||||
return (master_isotope_ptr);
|
return (master_isotope_ptr);
|
||||||
}
|
}
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|||||||
@ -61,10 +61,6 @@ initialize(void)
|
|||||||
stag_data->exch_f = 0;
|
stag_data->exch_f = 0;
|
||||||
stag_data->th_m = 0;
|
stag_data->th_m = 0;
|
||||||
stag_data->th_im = 0;
|
stag_data->th_im = 0;
|
||||||
/*
|
|
||||||
* Create hash tables
|
|
||||||
*/
|
|
||||||
hcreate_multi((unsigned) MAX_ELTS, &master_isotope_hash_table);
|
|
||||||
|
|
||||||
// user_print
|
// user_print
|
||||||
user_print = (struct rate *) PHRQ_malloc((size_t) sizeof(struct rate));
|
user_print = (struct rate *) PHRQ_malloc((size_t) sizeof(struct rate));
|
||||||
|
|||||||
@ -192,11 +192,10 @@ clean_up(void)
|
|||||||
/* master_isotope */
|
/* master_isotope */
|
||||||
for (i = 0; i < (int)master_isotope.size(); i++)
|
for (i = 0; i < (int)master_isotope.size(); i++)
|
||||||
{
|
{
|
||||||
master_isotope[i] = (struct master_isotope*)free_check_null(master_isotope[i]);
|
delete master_isotope[i];
|
||||||
}
|
}
|
||||||
master_isotope.clear();
|
master_isotope.clear();
|
||||||
hdestroy_multi(master_isotope_hash_table);
|
master_isotope_map.clear();
|
||||||
master_isotope_hash_table = NULL;
|
|
||||||
/* calculate_value */
|
/* calculate_value */
|
||||||
for (i = 0; i < (int)calculate_value.size(); i++)
|
for (i = 0; i < (int)calculate_value.size(); i++)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user