Making C++ classes final
[iot2.git] / iotjava / iotruntime / cpp / setrelation / IoTSet.hpp
index 78d8c63f2b49a8d7db1fcfb3aa7ddad4da6a55ad..e2a966d32dc4039de417a542383a91e80d7b6c8b 100644 (file)
@@ -13,12 +13,12 @@ using namespace std;
  * @since       2016-09-06
  */
 template <class T>
-class IoTSet {
+class IoTSet final {
        private:
-               unordered_set<T> set;
+               const unordered_set<T>* set;
        public:
                IoTSet();
-               IoTSet(unordered_set<T> const& s);
+               IoTSet(const unordered_set<T>* s);
                ~IoTSet();
        public:
                typename unordered_set<T>::const_iterator find(const T& k);     // Find the object
@@ -43,7 +43,7 @@ IoTSet<T>::IoTSet() {
  * Useful constructor
  */
 template <class T>
-IoTSet<T>::IoTSet(const unordered_set<T>& s) {
+IoTSet<T>::IoTSet(const unordered_set<T>* s) {
 
        set = s;
 }
@@ -64,7 +64,7 @@ IoTSet<T>::~IoTSet() {
 template <class T>
 typename unordered_set<T>::const_iterator IoTSet<T>::find(const T& k) {
 
-       return set.find(k);
+       return (new unordered_set<T>(*set))->find(k);
 }
 
 
@@ -74,7 +74,7 @@ typename unordered_set<T>::const_iterator IoTSet<T>::find(const T& k) {
 template <class T>
 typename unordered_set<T>::const_iterator IoTSet<T>::begin() {
 
-       return set.begin();
+       return (new unordered_set<T>(*set))->begin();
 }
 
 
@@ -84,7 +84,7 @@ typename unordered_set<T>::const_iterator IoTSet<T>::begin() {
 template <class T>
 typename unordered_set<T>::const_iterator IoTSet<T>::end() {
 
-       return set.end();
+       return (new unordered_set<T>(*set))->end();
 }
 
 
@@ -94,7 +94,7 @@ typename unordered_set<T>::const_iterator IoTSet<T>::end() {
 template <class T>
 int IoTSet<T>::size() {
 
-       return set.size();
+       return set->size();
 }
 
 
@@ -104,7 +104,7 @@ int IoTSet<T>::size() {
 template <class T>
 unordered_set<T>* IoTSet<T>::values() {
 
-       return new unordered_set<T>(set);
+       return new unordered_set<T>(*set);
 }
 #endif