1 #ifndef _IRELATION_HPP__
2 #define _IRELATION_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 IRelation(unordered_multimap<K,V> const* r);
24 typename unordered_multimap<K,V>::const_iterator find(const K& k); // Find the object based on key
25 typename unordered_multimap<K,V>::const_iterator insert(const pair<K,V>& val); // Insert the object pair
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 IRelation<K,V>::IRelation() {
43 rel = new unordered_multimap<K,V>();
50 template <class K,class V>
51 IRelation<K,V>::IRelation(const unordered_multimap<K,V>* r) {
60 template <class K,class V>
61 IRelation<K,V>::~IRelation() {
69 * Find the object k in the set
71 template <class K,class V>
72 typename unordered_multimap<K,V>::const_iterator IRelation<K,V>::find(const K& k) {
79 * Insert object k into the set
81 template <class K,class V>
82 typename unordered_multimap<K,V>::const_iterator IRelation<K,V>::insert(const pair<K,V>& val) {
84 return rel->insert(val);
89 * Return the "begin" iterator
91 template <class K,class V>
92 typename unordered_multimap<K,V>::const_iterator IRelation<K,V>::begin() {
99 * Return the "end" iterator
101 template <class K,class V>
102 typename unordered_multimap<K,V>::const_iterator IRelation<K,V>::end() {
109 * Return the "equal_range" iterator
111 template <class K,class V>
112 std::pair<typename unordered_multimap<K,V>::const_iterator,
113 typename unordered_multimap<K,V>::const_iterator>
114 IRelation<K,V>::equal_range(const K& k) {
116 return rel->equal_range(k);
121 * Return the size of the set
123 template <class K,class V>
124 int IRelation<K,V>::size() {
131 * Return a new copy of the set
133 template <class K,class V>
134 unordered_multimap<K,V> IRelation<K,V>::values() {