-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathList_view.cpp
44 lines (39 loc) · 1.17 KB
/
List_view.cpp
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
#include "List_view.h"
#include <iostream>
using std::cout; using std::endl;
using std::make_pair;
using std::string;
using std::vector;
void List_view::update_remove(const string& name)
{
object_info.erase(name);
}
void List_view::update_info(const string& name, double value)
{
auto result = object_info.insert(make_pair(name, value));
if(!result.second) {
// If the name already exists, update the value on record.
(result.first) -> second = value;
}
}
void List_view::plot(const string& name)
{
cout << "Current " << name << ":" << endl;
cout << "--------------" << endl;
for(auto it = object_info.begin(); it != object_info.end(); ++it) {
cout << it -> first << ": " << it -> second << endl;
}
cout << "--------------" << endl;
}
void List_view::plot_selected(const string& name, const vector<string>& objects) const
{
cout << name << endl;
cout << "--------------" << endl;
for(const string& name : objects) {
auto it = object_info.find(name);
if(it != object_info.end()) {
cout << it -> first << ": " << it -> second << endl;
}
}
cout << "--------------" << endl;
}