0.9.8.10
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
home
doug
src
hypertable
src
cc
Common
CstrHashTraits.h
Go to the documentation of this file.
1
/* -*- c++ -*-
2
* Copyright (C) 2007-2015 Hypertable, Inc.
3
*
4
* This file is part of Hypertable.
5
*
6
* Hypertable is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 3
9
* of the License, or any later version.
10
*
11
* Hypertable is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with Hypertable. If not, see <http://www.gnu.org/licenses/>
18
*/
19
24
#ifndef HYPERTABLE_CSTR_HASH_TRAITS_H
25
#define HYPERTABLE_CSTR_HASH_TRAITS_H
26
27
#include <
Common/PageArena.h
>
28
#include <
Common/TclHash.h
>
29
30
namespace
Hypertable
{
31
39
template
<
class
HashT = TclHash2>
40
struct
CstrHashTraits
{
41
typedef
CharArena
key_allocator
;
42
43
struct
hasher
{
44
HashT
hasher
;
45
46
size_t
operator()
(
const
char
*s)
const
{
return
hasher
(s); }
47
};
48
49
struct
key_equal
{
50
bool
51
operator()
(
const
char
*a,
const
char
*b)
const
{
52
return
std::strcmp(a, b) == 0;
53
}
54
};
55
};
56
57
inline
size_t
58
hash_case_cstr
(
const
char
*s) {
59
size_t
ret = 0;
60
61
for
(; *s; ++s)
62
ret += (ret << 3) + tolower((
unsigned
)*s);
63
64
return
ret;
65
}
66
67
struct
CstrCaseHashTraits
{
68
typedef
CharArena
key_allocator
;
69
70
struct
hasher
{
71
size_t
72
operator()
(
const
char
*s)
const
{
return
hash_case_cstr
(s); }
73
};
74
75
struct
key_equal
{
76
bool
77
operator()
(
const
char
*a,
const
char
*b)
const
{
78
for
(; tolower((
unsigned
)*a) == tolower((
unsigned
)*b); ++a, ++b)
79
if
(!*a)
80
return
true
;
81
82
return
false
;
83
}
84
};
85
};
86
89
}
// namespace Hypertable
90
91
#endif // !HYPERTABLE_CSTR_HASH_TRAITS_H
Hypertable::CstrHashTraits::hasher
Definition:
CstrHashTraits.h:43
Hypertable::CstrHashTraits::key_equal::operator()
bool operator()(const char *a, const char *b) const
Definition:
CstrHashTraits.h:51
PageArena.h
PageArena memory allocator.
Hypertable::CstrCaseHashTraits::hasher
Definition:
CstrHashTraits.h:70
Hypertable::CstrCaseHashTraits::key_equal
Definition:
CstrHashTraits.h:75
Hypertable::CstrHashTraits::key_allocator
CharArena key_allocator
Definition:
CstrHashTraits.h:41
Hypertable::CstrCaseHashTraits::key_allocator
CharArena key_allocator
Definition:
CstrHashTraits.h:68
Hypertable::PageArena
The PageArena allocator is simple and fast, avoiding individual mallocs/frees.
Definition:
PageArena.h:69
Hypertable::CstrCaseHashTraits::hasher::operator()
size_t operator()(const char *s) const
Definition:
CstrHashTraits.h:72
Hypertable::CstrCaseHashTraits
Definition:
CstrHashTraits.h:67
Hypertable::CstrHashTraits::hasher::hasher
HashT hasher
Definition:
CstrHashTraits.h:44
Hypertable
Hypertable definitions
Definition:
ApplicationHandler.h:36
Hypertable::CstrCaseHashTraits::key_equal::operator()
bool operator()(const char *a, const char *b) const
Definition:
CstrHashTraits.h:77
TclHash.h
Implementations of the Tcl hash algorithm by John Ousterhout.
Hypertable::CstrHashTraits::hasher::operator()
size_t operator()(const char *s) const
Definition:
CstrHashTraits.h:46
Hypertable::hash_case_cstr
size_t hash_case_cstr(const char *s)
Definition:
CstrHashTraits.h:58
Hypertable::CstrHashTraits
Traits for CstrHashMap/Set.
Definition:
CstrHashTraits.h:40
Hypertable::CstrHashTraits::key_equal
Definition:
CstrHashTraits.h:49
Generated on Tue Dec 22 2015 18:43:06 for Hypertable by
1.8.8