ANNA Suite  2020b
Multipurpose development suite for Telco applications
ExclusiveHash.hpp
Go to the documentation of this file.
1 // ANNA - Anna is Not Nothingness Anymore //
2 // //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
4 // //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7 
8 
9 #ifndef anna_core_util_ExclusiveHash_hpp
10 #define anna_core_util_ExclusiveHash_hpp
11 
12 #include <map>
13 
14 namespace anna {
15 
23 template < class T, class _K = unsigned long > class ExclusiveHash {
24  typedef std::map <T, _K> container;
25  typedef typename container::value_type value_type;
26 
27 public:
31  ExclusiveHash() : a_value(0) {;}
32 
37  _K calcule(const T& t)
38  {
39  typename container::iterator ii;
40  _K result = 0;
41 
42  if((ii = a_container.find(t)) == a_container.end()) {
43  result = a_value ++;
44  a_container.insert(value_type(t, result));
45  } else
46  result = ii->second;
47 
48  return result;
49  }
50 
51 private:
52  container a_container;
53  _K a_value;
54 };
55 
56 }
57 
58 #endif
ExclusiveHash()
Definition: ExclusiveHash.hpp:31
_K calcule(const T &t)
Definition: ExclusiveHash.hpp:37
Definition: app.hpp:12
Definition: ExclusiveHash.hpp:23