Ninja
hash_map.h
Go to the documentation of this file.
1
// Copyright 2011 Google Inc. All Rights Reserved.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#ifndef NINJA_MAP_H_
16
#define NINJA_MAP_H_
17
18
#include <algorithm>
19
#include <string.h>
20
#include "
string_piece.h
"
21
#include "
util.h
"
22
23
#include "third_party/emhash/hash_table8.hpp"
24
#include "
third_party/rapidhash/rapidhash.h
"
25
26
namespace
std
{
27
template
<>
28
struct
hash<
StringPiece
> {
29
typedef
StringPiece
argument_type
;
30
typedef
size_t
result_type
;
31
32
size_t
operator()
(
StringPiece
key)
const
{
33
return
rapidhash
(key.
str_
, key.
len_
);
34
}
35
};
36
}
37
38
/// A template for hash_maps keyed by a StringPiece whose string is
39
/// owned externally (typically by the values). Use like:
40
/// ExternalStringHash<Foo*>::Type foos; to make foos into a hash
41
/// mapping StringPiece => Foo*.
42
template
<
typename
V>
43
struct
ExternalStringHashMap
{
44
typedef
emhash8::HashMap<StringPiece, V>
Type
;
45
};
46
47
#endif
// NINJA_MAP_H_
std
Definition:
hash_map.h:26
rapidhash.h
rapidhash
RAPIDHASH_INLINE uint64_t rapidhash(const void *key, size_t len) RAPIDHASH_NOEXCEPT
Definition:
rapidhash.h:321
string_piece.h
ExternalStringHashMap
A template for hash_maps keyed by a StringPiece whose string is owned externally (typically by the va...
Definition:
hash_map.h:43
ExternalStringHashMap::Type
emhash8::HashMap< StringPiece, V > Type
Definition:
hash_map.h:44
StringPiece
StringPiece represents a slice of a string whose memory is managed externally.
Definition:
string_piece.h:25
StringPiece::str_
const char * str_
Definition:
string_piece.h:70
StringPiece::len_
size_t len_
Definition:
string_piece.h:71
std::hash< StringPiece >::argument_type
StringPiece argument_type
Definition:
hash_map.h:29
std::hash< StringPiece >::result_type
size_t result_type
Definition:
hash_map.h:30
std::hash< StringPiece >::operator()
size_t operator()(StringPiece key) const
Definition:
hash_map.h:32
util.h
Generated by
1.9.1