SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HashSet.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2011 Evgeniy Andreev (gsomix)
8  *
9  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
10  */
11 
12 #ifndef HASHSET_H_
13 #define HASHSET_H_
14 
15 #include <shogun/base/SGObject.h>
16 #include <shogun/lib/common.h>
17 #include <shogun/lib/Hash.h>
18 
19 namespace shogun
20 {
21 
22 #ifndef DOXYGEN_SHOULD_SKIP_THIS
23 
24 struct HashSetNode
25 {
27  int32_t key;
28 
30  float64_t data;
31 
33  HashSetNode *left;
34 
36  HashSetNode *right;
37 };
38 #endif
39 
43 class CHashSet: public CSGObject
44 {
45 public:
46  CHashSet();
47 
49  CHashSet(int32_t size);
50 
51  virtual inline const char* get_name() const
52  {
53  return "HashSet";
54  }
55 
56  virtual ~CHashSet();
57 
59  bool insert_key(int32_t key, float64_t data);
60 
62  bool search_key(int32_t key, float64_t &ret_data);
63 
65  void delete_key(int32_t key);
66 
68  void debug();
69 private:
73  int32_t hash(int32_t key);
74 
76  HashSetNode* chain_search(int32_t index, int32_t key);
77 
78 protected:
80  HashSetNode **hash_array;
81 
83  int32_t array_size;
84 };
85 
86 }
87 
88 #endif /* HASHSET_H_ */

SHOGUN Machine Learning Toolbox - Documentation