GiNaC 1.8.7
hash_seed.h
Go to the documentation of this file.
1
5#ifndef GINAC_HASH_SEED_H
6#define GINAC_HASH_SEED_H
7
8#include <typeinfo>
9#include <cstring>
10#include "utils.h"
11#ifdef _WIN32
12#define GINAC_HASH_USE_MANGLED_NAME 1
13#endif
14
15#ifdef GINAC_HASH_USE_MANGLED_NAME
16#include "crc32.h"
17#endif
18
19namespace GiNaC
20{
35#ifndef GINAC_HASH_USE_MANGLED_NAME
36static inline unsigned make_hash_seed(const std::type_info& tinfo)
37{
38 // This pointer is the same for all objects of the same type.
39 // Hence we can use it.
40 const void* mangled_name_ptr = (const void*)tinfo.name();
41 unsigned v = golden_ratio_hash((uintptr_t)mangled_name_ptr);
42 return v;
43}
44#else
45static unsigned make_hash_seed(const std::type_info& tinfo)
46{
47 const char* mangled_name = tinfo.name();
48 return crc32(mangled_name, std::strlen(mangled_name), 0);
49}
50#endif
51} // namespace GiNaC
52#endif /* GINAC_HASH_SEED_H */
53
54
CRC32 hash function.
Definition: add.cpp:38
unsigned golden_ratio_hash(uintptr_t n)
Truncated multiplication with golden ratio, for computing hash values.
Definition: utils.h:68
static unsigned make_hash_seed(const std::type_info &tinfo)
We need a hash function which gives different values for objects of different types.
Definition: hash_seed.h:36
static unsigned crc32(const char *c, const unsigned len, const unsigned crcinit)
Definition: crc32.h:66
Interface to several small and furry utilities needed within GiNaC but not of any interest to the use...

This page is part of the GiNaC developer's reference. It was generated automatically by doxygen. For an introduction, see the tutorial.