Skip to content

Commit

Permalink
Added a typedef for the map type.
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierandrade committed Jun 28, 2018
1 parent 1de2fda commit 94db5a5
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/pseudo/element.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,36 @@ namespace pseudopotential {

class element {

public:
private:

struct properties;
typedef std::map<std::string, properties> map_type;

public:

element(const std::string & symbol = "none"):symbol_(trim(symbol)){
symbol_[0] = std::toupper(symbol_[0]);
for(unsigned ii = 1; ii < symbol_.size(); ii++) symbol_[ii] = std::tolower(symbol_[ii]);

map(); //make sure the map is initialized
}

element(int atomic_number){

//special case: avoid ambiguity between isotopes
if(atomic_number == 1){
symbol_ = 'H';
return;
}

for(map_type::iterator it = map().begin(); it != map().end(); ++it){
if(it->second.z_ == atomic_number) {
symbol_ = it->first;
break;
}
}
}

bool valid() const {
return map().find(symbol_) != map().end();
}
Expand Down Expand Up @@ -75,9 +96,9 @@ namespace pseudopotential {
double vdw_radius_;
};

static std::map<std::string, properties> & map(){
static map_type & map(){

static std::map<std::string, properties> map;
static map_type map;

if(map.empty()){

Expand Down

0 comments on commit 94db5a5

Please sign in to comment.