CluE  1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
distinctelementsprimitive.h
Go to the documentation of this file.
1 #ifndef DISTINCTELEMENTSPRIMITIVE_H
2 #define DISTINCTELEMENTSPRIMITIVE_H
3 
4 #include <set>
5 #include <functional>
6 
7 #include "../hashing/hashfunction.h"
8 
9 namespace CluE
10 {
11 
15 template<typename U, typename H> class DistinctElementsPrimitive
16 {
17 
18 public:
19  DistinctElementsPrimitive(unsigned long long sizeOfUniverse, double eps, std::function<HashFunction<U,H>*(unsigned long long sizeOfHashingSpace)> hashfunctionCreator) :
20  elements()
21  {
22  }
23 
25  {
26  }
27 
28  DistinctElementsPrimitive<U,H>& operator<<(U const & element);
29 
30  unsigned long long numberOfDistinctElements();
31 
32 private:
33  std::set<U> elements;
34 };
35 
36 template<typename U, typename H> DistinctElementsPrimitive<U,H>& DistinctElementsPrimitive<U,H>::operator<<(U const & element)
37 {
38  elements.insert(element);
39  return *this;
40 }
41 
42 template<typename U, typename H> unsigned long long DistinctElementsPrimitive<U,H>::numberOfDistinctElements()
43 {
44  return elements.size();
45 }
46 
47 }
48 
49 #endif
DistinctElementsPrimitive< U, H > & operator<<(U const &element)
Base class template for any hash function mapping an element from universe U to hashing space H...
Definition: hashfunction.h:10
Count distinct elements in a stream using a std::set (for debugging)
DistinctElementsPrimitive(unsigned long long sizeOfUniverse, double eps, std::function< HashFunction< U, H > *(unsigned long long sizeOfHashingSpace)> hashfunctionCreator)