removed old style usage of hash map and substituted with c+11 sytle unordered set and map.

This commit is contained in:
Paolo Cignoni 2015-09-13 06:20:20 +00:00
parent ad95129d02
commit 47aaea332a
1 changed files with 86 additions and 122 deletions

View File

@ -24,34 +24,7 @@
#ifndef VCG_MATH_UNIONSET_H
#define VCG_MATH_UNIONSET_H
// some stuff for portable hashes...
#ifdef WIN32
#ifndef __MINGW32__
#include <hash_map>
#include <hash_set>
#define STDEXT stdext
#else
#include <ext/hash_map>
#include <ext/hash_set>
#define STDEXT __gnu_cxx
#endif
#else
#include <ext/hash_map>
#include <ext/hash_set>
#define STDEXT __gnu_cxx
// It's terrible but gnu's hash_map needs an instantiation of hash() for
// every key type! So we cast the pointer to void*
namespace __gnu_cxx
{
template <> class hash<void *>: private hash<unsigned long>
{
public:
size_t operator()(const void *ptr) const { return hash<unsigned long>::operator()((unsigned long)ptr); }
};
}
#endif
#include <unordered_map>
#include <vector>
#include <assert.h>
@ -83,21 +56,12 @@ namespace vcg
inline size_t operator ()(const ObjectPointer &p) const {return size_t(p);}
};
#ifdef _MSC_VER
STDEXT::hash_map< OBJECT_TYPE*, int > inserted_objects;
typedef typename STDEXT::hash_map< ObjectPointer, int >::iterator hIterator;
#else
STDEXT::hash_map< OBJECT_TYPE*, int, SimpleObjHashFunc > inserted_objects;
typedef typename STDEXT::hash_map< ObjectPointer, int, SimpleObjHashFunc >::iterator hIterator;
#endif
std::unordered_map< OBJECT_TYPE*, int > inserted_objects;
typedef typename std::unordered_map< OBJECT_TYPE*, int >::iterator hIterator;
typedef std::pair< hIterator, bool > hInsertResult;
public:
/*!
* Default constructor