-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_utilities.hpp
77 lines (71 loc) · 1.04 KB
/
my_utilities.hpp
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
#pragma once
#include<string>
#include<vector>
using std::string;
using std::vector;
struct vs_auto_iterator
{
typedef vector<string>::iterator vs_iter;
vs_iter start_iter;
vs_iter end_iter;
vs_iter cur_iter;
bool reaches_end = false;
bool at_start = false;
vs_auto_iterator(vector<string>& vs_out_op)
:
start_iter(vs_out_op.begin()),
end_iter(vs_out_op.end()),
cur_iter(vs_out_op.begin())
{
at_start = true;
}
string str()
{
if (reaches_end)
{
return "";
}
else
return *(cur_iter);
}
vs_auto_iterator operator++()
{
if (cur_iter == end_iter)
{
reaches_end = true;
}
else
{
if (cur_iter == start_iter)
{
at_start = false;
}
++cur_iter;
if (cur_iter == end_iter)
{
reaches_end = true;
}
}
return *this;
}
vs_auto_iterator operator--()
{
if (cur_iter == start_iter)
{
at_start = true;
}
else
{
if (cur_iter == end_iter)
{
reaches_end = false;
}
--cur_iter;
if (cur_iter == start_iter)
{
at_start = true;
}
return *this;
}
}
};