Replaced google sparsehash by boost unordered map
This commit is contained in:
parent
e8699d4337
commit
d07994bd73
@ -28,9 +28,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <google/dense_hash_map>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <google/sparse_hash_map>
|
|
||||||
#include <google/sparsetable>
|
|
||||||
|
|
||||||
template< typename NodeID, typename Key >
|
template< typename NodeID, typename Key >
|
||||||
class ArrayStorage {
|
class ArrayStorage {
|
||||||
@ -74,10 +72,10 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template< typename NodeID, typename Key >
|
template< typename NodeID, typename Key >
|
||||||
class DenseStorage {
|
class UnorderedMapStorage {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DenseStorage( size_t size = 0 ) { nodes.set_empty_key(UINT_MAX); }
|
UnorderedMapStorage( size_t size = 0 ) { }
|
||||||
|
|
||||||
Key &operator[]( NodeID node ) {
|
Key &operator[]( NodeID node ) {
|
||||||
return nodes[node];
|
return nodes[node];
|
||||||
@ -88,34 +86,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
google::dense_hash_map< NodeID, Key > nodes;
|
boost::unordered_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();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename NodeID = unsigned>
|
template<typename NodeID = unsigned>
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
#include <climits>
|
#include <climits>
|
||||||
#include <google/sparse_hash_map>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <boost/unordered_map.hpp>
|
||||||
|
|
||||||
template < class T >
|
template < class T >
|
||||||
struct Countfn {
|
struct Countfn {
|
||||||
unsigned long operator()( const T &x ) { return 1; }
|
unsigned long operator()( const T &x ) { return 1; }
|
||||||
@ -17,7 +18,7 @@ public:
|
|||||||
typedef std::vector< Key > Key_List; ///< List of keys
|
typedef std::vector< Key > Key_List; ///< List of keys
|
||||||
typedef typename Key_List::iterator Key_List_Iter; ///< Main cache iterator
|
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 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 std::pair< Key, List_Iter > Pair; ///< Pair of Map elements
|
||||||
typedef typename Map::iterator Map_Iter; ///< Index iterator
|
typedef typename Map::iterator Map_Iter; ///< Index iterator
|
||||||
typedef typename Map::const_iterator Map_cIter; ///< Index iterator (const)
|
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
|
unsigned long _curr_size; ///< Current abstract size of the cache
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LRUCache( const unsigned long Size ) : _max_size( Size ), _curr_size( 0 ) {
|
LRUCache( const unsigned long Size ) : _max_size( Size ), _curr_size( 0 ) { }
|
||||||
_index.set_deleted_key(UINT_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
~LRUCache() { clear(); }
|
~LRUCache() { clear(); }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user