Repository navigation
Expand file tree
/
Copy pathCSyntheticInfos.cpp
More file actions
91 lines (78 loc) · 1.85 KB
/
Copy pathCSyntheticInfos.cpp
File metadata and controls
91 lines (78 loc) · 1.85 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include "stdafx.h"
#include "CSyntheticInfos.h"
CSyntheticInfos::CSyntheticInfos()
{
}
CSyntheticInfos::~CSyntheticInfos()
{
}
void CSyntheticInfos::Add_Product(const char* product, const char* instrument, double weight)
{
auto it = m_map_by_product.find(product);
if (it == m_map_by_product.end())
{
// 没找到
unordered_map<string, double> sd;
sd.insert(pair<string, double>(instrument, weight));
m_map_by_product.insert(pair<string, unordered_map<string, double>>(product, sd));
m_list_product.push_back(product);
}
else
{
// 找到了
it->second.insert(pair<string, double>(instrument, weight));
}
}
void CSyntheticInfos::Add_Instrument(const char* instrument, const char* product, double weight)
{
auto it = m_map_by_instrument.find(instrument);
if (it == m_map_by_instrument.end())
{
// 没找到
unordered_map<string, double> sd;
sd.insert(pair<string, double>(product, weight));
m_map_by_instrument.insert(pair<string, unordered_map<string, double>>(instrument, sd));
}
else
{
// 找到了
it->second.insert(pair<string, double>(product, weight));
}
}
void CSyntheticInfos::Add(const char* product, const char* instrument, double weight)
{
Add_Product(product, instrument, weight);
Add_Instrument(instrument, product, weight);
}
unordered_map<string, double> CSyntheticInfos::GetByProduct(const char* product)
{
auto it = m_map_by_product.find(product);
if (it == m_map_by_product.end())
{
// 没找到
unordered_map<string, double> sd;
return sd;
}
else
{
return it->second;
}
}
unordered_map<string, double> CSyntheticInfos::GetByInstrument(const char* product)
{
auto it = m_map_by_instrument.find(product);
if (it == m_map_by_instrument.end())
{
// 没找到
unordered_map<string, double> sd;
return sd;
}
else
{
return it->second;
}
}
list<string> CSyntheticInfos::GetProducts()
{
return m_list_product;
}