Replaced google sparsehash by boost unordered map

This commit is contained in:
DennisOSRM 2011-12-10 14:09:40 +01:00
parent e8699d4337
commit d07994bd73
2 changed files with 8 additions and 38 deletions

View File

@ -28,9 +28,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include <vector>
#include <algorithm>
#include <map>
#include <google/dense_hash_map>
#include <google/sparse_hash_map>
#include <google/sparsetable>
#include <boost/unordered_map.hpp>
template< typename NodeID, typename Key >
class ArrayStorage {
@ -74,10 +72,10 @@ private:
};
template< typename NodeID, typename Key >
class DenseStorage {
class UnorderedMapStorage {
public:
DenseStorage( size_t size = 0 ) { nodes.set_empty_key(UINT_MAX); }
UnorderedMapStorage( size_t size = 0 ) { }
Key &operator[]( NodeID node ) {
return nodes[node];
@ -88,34 +86,7 @@ public:
}
private:
google::dense_hash_map< NodeID, Key > nodes;
};
template< typename NodeID, typename Key >
class SparseStorage {
public:
SparseStorage( size_t size = 0 ) { }
Key &operator[]( NodeID node ) {
return nodes[node];
}
void Clear() {
nodes.clear();
}
private:
google::sparse_hash_map< NodeID, Key > nodes;
};
template< typename NodeID, typename Key >
class SparseTableStorage : public google::sparsetable<NodeID> {
public:
SparseTableStorage(size_t n) : google::sparsetable<NodeID>(n){ }
void Clear() {
google::sparsetable<NodeID>::clear();
}
boost::unordered_map< NodeID, Key > nodes;
};
template<typename NodeID = unsigned>

View File

@ -1,9 +1,10 @@
#include <climits>
#include <google/sparse_hash_map>
#include <iostream>
#include <list>
#include <vector>
#include <boost/unordered_map.hpp>
template < class T >
struct Countfn {
unsigned long operator()( const T &x ) { return 1; }
@ -17,7 +18,7 @@ public:
typedef std::vector< Key > Key_List; ///< List of keys
typedef typename Key_List::iterator Key_List_Iter; ///< Main cache iterator
typedef typename Key_List::const_iterator Key_List_cIter; ///< Main cache iterator (const)
typedef google::sparse_hash_map< Key, List_Iter > Map; ///< Index typedef
typedef boost::unordered_map< Key, List_Iter > Map; ///< Index typedef
typedef std::pair< Key, List_Iter > Pair; ///< Pair of Map elements
typedef typename Map::iterator Map_Iter; ///< Index iterator
typedef typename Map::const_iterator Map_cIter; ///< Index iterator (const)
@ -29,9 +30,7 @@ private:
unsigned long _curr_size; ///< Current abstract size of the cache
public:
LRUCache( const unsigned long Size ) : _max_size( Size ), _curr_size( 0 ) {
_index.set_deleted_key(UINT_MAX);
}
LRUCache( const unsigned long Size ) : _max_size( Size ), _curr_size( 0 ) { }
~LRUCache() { clear(); }