summaryrefslogtreecommitdiff
path: root/src/maps/hash.cpp
blob: b3d80d111b5b0b11d3371786e0b1527b6c5a84e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef HASH_CPP
#define HASH_CPP

#include "hash.h"

int
hash::operator()(string s_key) const
{
  int i_hash = 0;
  //  cout << key << "%";

  int i_size = s_key.size();

  for( size_t i = 0; i < i_size; ++i )
    i_hash =  ( i_hash << 5 ) ^ s_key.at(i) ^ i_hash;

  return i_hash;
}

bool
hashmap_allocator::operator()(string s_key_1, string s_key_2) const
{
  return s_key_1.compare(s_key_2) == 0;
}

#endif