-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobal.cpp
More file actions
28 lines (21 loc) · 735 Bytes
/
global.cpp
File metadata and controls
28 lines (21 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <vector>
#include <iostream>
#include <map>
#include <fstream>
#include "global.h"
using namespace std;
map<int, vector<float>> LoadVectorsFromBinary(){
ifstream in(vectorFile, ios::binary);
size_t mapSize;
map<int, vector<float>> vMap;
in.read(reinterpret_cast<char*>(&mapSize), sizeof(mapSize));
in.read(reinterpret_cast<char*>(&vectorSize), sizeof(vectorSize));
for (size_t i = 0; i < mapSize; ++i){
int key;
vector<float> vec(vectorSize);
in.read(reinterpret_cast<char*>(&key), sizeof(key));
in.read(reinterpret_cast<char*>(vec.data()), vectorSize * sizeof(float));
vMap[key] = move(vec); // Moves the owner ship of the memory
}
return vMap;
}