~davidagraf/zorba/trace_without_debug_info

« back to all changes in this revision

Viewing changes to src/zorbautils/hashmap_zstring_nonserializable.h

  • Committer: David Graf
  • Date: 2012-06-27 07:20:59 UTC
  • mfrom: (10869.1.25 zorba)
  • Revision ID: davidagraf@gmail.com-20120627072059-723duu6vsbqu60ax
merged trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2006-2008 The FLWOR Foundation.
3
 
 * 
4
 
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 
 * you may not use this file except in compliance with the License.
6
 
 * You may obtain a copy of the License at
7
 
 * 
8
 
 * http://www.apache.org/licenses/LICENSE-2.0
9
 
 * 
10
 
 * Unless required by applicable law or agreed to in writing, software
11
 
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 
 * See the License for the specific language governing permissions and
14
 
 * limitations under the License.
15
 
 */
16
 
#pragma once
17
 
#ifndef ZORBA_HASHMAP_ZSTRING_NONSERIALIZABLE
18
 
#define ZORBA_HASHMAP_ZSTRING_NONSERIALIZABLE
19
 
 
20
 
#undef ZORBA_UTILS_HASHMAP_WITH_SERIALIZATION
21
 
#include "zorbautils/hashmap.h"
22
 
 
23
 
#include "zorbatypes/zstring.h"
24
 
 
25
 
#include "util/utf8_util.h"
26
 
 
27
 
 
28
 
namespace zorba
29
 
{
30
 
 
31
 
/***************************************************************************//**
32
 
  Class to privide the equality and hash functions for the HashMapZString
33
 
  class defined below.
34
 
*******************************************************************************/
35
 
class HashMapZStringCmp
36
 
{
37
 
public:
38
 
  static uint32_t hash(const zstring& str)
39
 
  {
40
 
    return utf8::hash(str);
41
 
  }
42
 
 
43
 
  static bool equal(const zstring& s1, const zstring& s2)
44
 
  {
45
 
    return s1 == s2;
46
 
  }
47
 
};
48
 
 
49
 
 
50
 
/*******************************************************************************
51
 
  A nonserializable hash-based map container mapping zstrings to values of
52
 
  type V. Equality is based on the zstring == operator.
53
 
*******************************************************************************/
54
 
template<class V>
55
 
class HashMapZString : public HashMap<zstring, V, HashMapZStringCmp>
56
 
{
57
 
public:
58
 
  HashMapZString()
59
 
    :
60
 
    HashMap<zstring, V, HashMapZStringCmp>()
61
 
  {
62
 
  }
63
 
 
64
 
public:
65
 
  HashMapZString(ulong size, bool sync)
66
 
    :
67
 
    HashMap<zstring, V, HashMapZStringCmp>(size, sync)
68
 
  {
69
 
  }
70
 
 
71
 
  virtual ~HashMapZString() {  }
72
 
};
73
 
 
74
 
}
75
 
 
76
 
#endif