COVISE Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
coStringMultiHash.h
Go to the documentation of this file.
1 /* This file is part of COVISE.
2 
3  You can use it under the terms of the GNU Lesser General Public License
4  version 2.1 or later, see lgpl-2.1.txt.
5 
6  * License: LGPL 2+ */
7 
8 #ifndef _CO_STRING_MULTI_HASH_H_
9 #define _CO_STRING_MULTI_HASH_H_
10 
11 #include "coMultiHash.h"
12 
13 #include <cstring>
14 
15 // 24.02.01
16 
21 namespace covise
22 {
23 
24 template <class DATA>
25 class coStringMultiHash : public coMultiHash<const char *, DATA>
26 {
27 
28 public:
29  // constructor with NULL element
30  coStringMultiHash(const DATA &nullelem)
31  : coMultiHash<const char *, DATA>(nullelem){};
32 
33  // constructor without NULL element
35  : coMultiHash<const char *, DATA>(){};
36 
37 private:
38  // Copy-Constructor: NOT IMPLEMENTED
40 
41  // Assignment operator: NOT IMPLEMENTED
43 
45  unsigned long hash1(const char *const &key) const
46  {
47  int h;
48  const char *t = key;
49  for (h = 0; *t; t++)
50  h = (64 * h + *t) % this->size;
51  return (h);
52  }
53 
55  unsigned long hash2(const char *const &key) const
56  {
57  int h;
58  const char *t = key;
59  for (h = 0; *t; t++)
60  h = (64 * h + *t) % (this->size - 2);
61  return (this->size - 2 - h);
62  }
63 
65  bool equal(const char *const &key1, const char *const &key2) const
66  //{ if((key1)&&(key2)) return( key1==key2) ); else return 0; }
67  {
68  if (NULL == key1)
69  return (false);
70  if (NULL == key2)
71  return (false);
72  return (0 == strcmp(key1, key2));
73  }
74 };
75 }
76 #endif
GLfloat GLfloat GLfloat GLfloat h
Definition: khronos-glext.h:8441
unsigned long hash1(const char *const &key) const
1st Hash function
Definition: coStringMultiHash.h:45
GLuint64EXT GLuint GLuint GLenum GLenum GLuint GLuint GLenum GLuint GLuint key1
Definition: khronos-glext.h:11877
bool equal(const char *const &key1, const char *const &key2) const
Equal function.
Definition: coStringMultiHash.h:65
coStringMultiHash()
Definition: coStringMultiHash.h:34
unsigned long hash2(const char *const &key) const
2nd Hash function
Definition: coStringMultiHash.h:55
#define NULL
Definition: covise_list.h:22
coStringMultiHash(const DATA &nullelem)
Definition: coStringMultiHash.h:30
GLsizeiptr size
Definition: khronos-glext.h:6610
GLint GLint GLint GLint GLint x
Definition: khronos-glext.h:6346
unsigned int size
size of the list
Definition: coMultiHashBase.h:95
Definition: coStringMultiHash.h:25
Definition: coHashIter.h:23
coStringMultiHash & operator=(const coStringMultiHash &x)
GLdouble GLdouble t
Definition: khronos-glext.h:6449