-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathсontaier.cpp
117 lines (95 loc) · 2.28 KB
/
сontaier.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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
@author: Sir0ga90
@version: 0.1
@date: 04.10.2016
*/
//=============================================
#include <random>
#include <ctime>
#include <iomanip>
#include "ñontainer.h"
//=============================================
/*
Common fill of main containers
in: _map - main map
in: _vec - main vector
*/
void fill(MMap& _map, MVec& _vec){
printSepLine();
cout << "___Here is init containers___\n\n";
fillContainers(_map, _vec);
printMapAndVec(_map, _vec);
printSepLine();
}
//=============================================
/*
in: _map - main map
in: _vec - main vector
*/
void fillContainers(MMap& _map, MVec& _vec){
fillRandMap(_map);
fillRandVec(_vec);
}
//=============================================
/*
Fill main map with random numbers from 1 to 9.
in: _map - main map
*/
void fillRandMap(MMap& _map){
srand( (unsigned)time(0) );
for (int i = 0; i < MAX_SZ; i++){
++_map[rand() % 10];
}
}
//=============================================
/*
Fill main vector with random numbers from 1 to 9.
in: _vec - main vector
*/
void fillRandVec(MVec& _vec){
for(int i = 0; i < MAX_SZ; i++){
_vec.push_back( rand() % 10 );
}
}
//=============================================
/*
Print main map & it's size
in: _mM - main map
*/
void printMap(const MMap& _mM){
for(const auto& elem : _mM){
cout << " [" << elem.first << ", " << elem.second << "]";
}
cout << endl << " size() == " << _mM.size()
<< endl << endl;
}
//=============================================
/*
Print main vector & it's size
in: _mV - main vector
*/
void printVec(MVec& _mV){
for(auto x : _mV){
cout << " [" << x << "]";
}
cout << endl << " size() == " << _mV.size() << endl;
}
//=============================================
/*
Common print of containers
in: _map - main map
in: _vec - main vector
*/
void printMapAndVec(MMap& _myM,
MVec& _myV){
printMap(_myM);
printVec(_myV);
}
//=============================================
/*
Print separator line in view of "------------"
*/
void printSepLine(void){
cout << setfill('-') << setw(80) << "-";
}
//=============================================