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>
18 unordered_multimap<K,V> rel;
21 IoTRelation(unordered_multimap<K,V> const& s);
24 typename unordered_multimap<K,V>::const_iterator find(const K& k); // Find the object based on key
25 bool empty(); // Test is empty?
26 typename unordered_multimap<K,V>::const_iterator begin(); // Iterator
27 typename unordered_multimap<K,V>::const_iterator end(); // Iterator
28 std::pair<typename unordered_multimap<K,V>::const_iterator,
29 typename unordered_multimap<K,V>::const_iterator>
30 equal_range(const K& k); // Equal range iterator
31 int size(); // Set size
32 unordered_multimap<K,V> values(); // Return set contents
39 template <class K,class V>
40 IoTRelation<K,V>::IoTRelation() {
48 template <class K,class V>
49 IoTRelation<K,V>::IoTRelation(const unordered_multimap<K,V>& r) {
58 template <class K,class V>
59 IoTRelation<K,V>::~IoTRelation() {
66 * Find the object k in the set
68 template <class K,class V>
69 typename unordered_multimap<K,V>::const_iterator IoTRelation<K,V>::find(const K& k) {
76 * Return the "begin" iterator
78 template <class K,class V>
79 typename unordered_multimap<K,V>::const_iterator IoTRelation<K,V>::begin() {
86 * Return the "end" iterator
88 template <class K,class V>
89 typename unordered_multimap<K,V>::const_iterator IoTRelation<K,V>::end() {
96 * Return the "equal_range" iterator
98 template <class K,class V>
99 std::pair<typename unordered_multimap<K,V>::const_iterator,
100 typename unordered_multimap<K,V>::const_iterator>
101 IoTRelation<K,V>::equal_range(const K& k) {
103 return rel.equal_range(k);
108 * Return the size of the set
110 template <class K,class V>
111 int IoTRelation<K,V>::size() {
118 * Return a new copy of the set
120 template <class K,class V>
121 unordered_multimap<K,V> IoTRelation<K,V>::values() {
123 return new unordered_multimap<K,V>(rel);