moved Hashmap also in api package
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
//
|
||||
|
||||
#include "API.h"
|
||||
#include "../Hashmap.h"
|
||||
#include "Hashmap.h"
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
|
||||
#include <string>
|
||||
#include "../Hashmap.h"
|
||||
#include "Hashmap.h"
|
||||
|
||||
class API {
|
||||
public:
|
||||
|
47
src/api/Hashmap.h
Normal file
47
src/api/Hashmap.h
Normal 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
|
Reference in New Issue
Block a user