1
/*------------------------------------------------------------------------------
2
* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
4
* Distributable under the terms of either the Apache License (Version 2.0) or
5
* the GNU Lesser General Public License, as specified in the COPYING file.
6
------------------------------------------------------------------------------*/
7
//note: you may be bound by the google license if you choose
8
//to compile your source code with the google sparsemap library
9
#ifndef _lucene_util_GoogleSparseMaps_H
10
#define _lucene_util_GoogleSparseMaps_H
12
#if defined(_LUCENE_PRAGMA_ONCE)
16
#ifdef _CL_HAVE_GOOGLE_DENSE_HASH_MAP
18
#include <google/dense_hash_map>
23
template<typename _Type, typename _Equals>
24
class SparseMapEquals{
27
bool operator()( _Type val1, _Type val2 ) const{
30
else if ( val1 == NULL || val2 == NULL )
32
else if ( val1 == (_Type)0x02 || val2 == (_Type)0x02 )
34
return equals(val1,val2);
38
template<typename _kt, typename _vt,
41
typename _KeyDeletor=CL_NS(util)::Deletor::Dummy,
42
typename _ValueDeletor=CL_NS(util)::Deletor::Dummy >
43
class CLHashMap:public __CLMap<_kt,_vt,
44
GOOGLE_NAMESPACE::dense_hash_map<_kt,_vt, _Hasher, SparseMapEquals<_kt,_Equals> >,
45
_KeyDeletor,_ValueDeletor>
47
typedef __CLMap<_kt,_vt,
48
GOOGLE_NAMESPACE::dense_hash_map<_kt,_vt, _Hasher, SparseMapEquals<_kt,_Equals> >,
49
_KeyDeletor,_ValueDeletor> _this;
51
CLHashMap ( bool deleteKey=false, bool deleteValue=false )
53
GOOGLE_NAMESPACE::dense_hash_map<_kt,_vt, _Hasher, SparseMapEquals<_kt,_Equals> >::set_empty_key(NULL);
54
GOOGLE_NAMESPACE::dense_hash_map<_kt,_vt, _Hasher, SparseMapEquals<_kt,_Equals> >::set_deleted_key((_kt)0x02);
55
_this::setDeleteKey(deleteKey);
56
_this::setDeleteValue(deleteValue);
65
#endif //LUCENE_USE_GOOGLEMAPS