DynuIPRefresher/src/api/Hashmap.h

51 lines
1005 B
C
Raw Normal View History

2019-05-01 09:14:52 +00:00
//
// Created by lukas on 07.04.19.
//
#ifndef QT5PROJECT_HASHMAP_H
#define QT5PROJECT_HASHMAP_H
#include <iostream>
#include <vector>
2019-05-08 17:31:49 +00:00
template<class keytype, class valuetype>
class Hashmap {
2019-05-01 09:14:52 +00:00
public:
2019-05-08 17:31:49 +00:00
void add(keytype key, keytype value);
2019-05-01 09:14:52 +00:00
keytype getKey(int position);
2019-05-08 17:31:49 +00:00
2019-05-01 09:14:52 +00:00
valuetype getValue(int position);
int size();
private:
std::vector<keytype> keys;
std::vector<valuetype> values;
};
template<class keytype, class valuetype>
void Hashmap<keytype, valuetype>::add(keytype key, keytype value) {
keys.push_back(key);
values.push_back(value);
}
template<class keytype, class valuetype>
keytype Hashmap<keytype, valuetype>::getKey(int position) {
return keys.at(position);
}
template<class keytype, class valuetype>
valuetype Hashmap<keytype, valuetype>::getValue(int position) {
return values.at(position);
}
template<class keytype, class valuetype>
int Hashmap<keytype, valuetype>::size() {
2019-05-11 09:09:48 +00:00
return (int)(keys.size());
2019-05-01 09:14:52 +00:00
}
#endif //QT5PROJECT_HASHMAP_H