moved Hashmap also in api package

This commit is contained in:
2019-05-08 19:28:16 +02:00
parent 846a32ee7e
commit 31819abcaf
4 changed files with 3 additions and 3 deletions

View File

@ -3,7 +3,7 @@
//
#include "API.h"
#include "../Hashmap.h"
#include "Hashmap.h"
#include <string>
#include <iostream>

View File

@ -7,7 +7,7 @@
#include <string>
#include "../Hashmap.h"
#include "Hashmap.h"
class API {
public:

47
src/api/Hashmap.h Normal file
View File

@ -0,0 +1,47 @@
//
// Created by lukas on 07.04.19.
//
#ifndef QT5PROJECT_HASHMAP_H
#define QT5PROJECT_HASHMAP_H
#include <iostream>
#include <vector>
template <class keytype,class valuetype> class Hashmap {
public:
void add(keytype key,keytype value);
keytype getKey(int position);
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() {
return keys.size();
}
#endif //QT5PROJECT_HASHMAP_H