1 #ifndef _IOTRELATION_HPP__
2 #define _IOTRELATION_HPP__
5 #include <unordered_map>
9 /** This is the IoTRelation implementation for C++
11 * @author Rahmadi Trimananda <rahmadi.trimananda @ uci.edu>
15 template <class K,class V>
16 class IoTRelation final {
18 const unordered_multimap<K,V>* rel;
21 //IoTRelation(unordered_multimap<K,V> const& s);
22 IoTRelation(const unordered_multimap<K,V>* s);
25 typename unordered_multimap<K,V>::const_iterator find(const K& k); // Find the object based on key
26 bool empty(); // Test is empty?
27 typename unordered_multimap<K,V>::const_iterator begin(); // Iterator
28 typename unordered_multimap<K,V>::const_iterator end(); // Iterator
29 std::pair<typename unordered_multimap<K,V>::const_iterator,
30 typename unordered_multimap<K,V>::const_iterator>
31 equal_range(const K& k); // Equal range iterator
32 int size(); // Set size
33 unordered_multimap<K,V>* values(); // Return set contents
40 template <class K,class V>
41 IoTRelation<K,V>::IoTRelation() {
49 template <class K,class V>
50 //IoTRelation<K,V>::IoTRelation(const unordered_multimap<K,V>& r) {
51 IoTRelation<K,V>::IoTRelation(const unordered_multimap<K,V>* r) {
60 template <class K,class V>
61 IoTRelation<K,V>::~IoTRelation() {
67 * Find the object k in the set
69 template <class K,class V>
70 typename unordered_multimap<K,V>::const_iterator IoTRelation<K,V>::find(const K& k) {
72 return (new unordered_multimap<K,V>(*rel))->find(k);
77 * Return the "begin" iterator
79 template <class K,class V>
80 typename unordered_multimap<K,V>::const_iterator IoTRelation<K,V>::begin() {
82 return (new unordered_multimap<K,V>(*rel))->begin();
87 * Return the "end" iterator
89 template <class K,class V>
90 typename unordered_multimap<K,V>::const_iterator IoTRelation<K,V>::end() {
92 return (new unordered_multimap<K,V>(*rel))->end();
97 * Return the "equal_range" iterator
99 template <class K,class V>
100 std::pair<typename unordered_multimap<K,V>::const_iterator,
101 typename unordered_multimap<K,V>::const_iterator>
102 IoTRelation<K,V>::equal_range(const K& k) {
104 return (new unordered_multimap<K,V>(*rel))->equal_range(k);
109 * Return the size of the set
111 template <class K,class V>
112 int IoTRelation<K,V>::size() {
119 * Return a new copy of the set
121 template <class K,class V>
122 unordered_multimap<K,V>* IoTRelation<K,V>::values() {
124 return new unordered_multimap<K,V>(*rel);