Skip to content

Commit 45de90f

Browse files
committed
fix private field name
1 parent f860d5b commit 45de90f

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

task_02/src/list_stacks.hpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,59 +7,59 @@ template <typename T>
77
class Stack final {
88
public:
99
constexpr Stack() noexcept {}
10-
Stack(const Stack& other) : list(other.list) {}
11-
Stack(Stack&& other) : list(other.list) { other.list.clear(); }
12-
Stack(const std::initializer_list<T>& init_list) : list(init_list) {}
10+
Stack(const Stack& other) : list_(other.list_) {}
11+
Stack(Stack&& other) : list_(std::move(other.list_)) { other.list_.clear(); }
12+
Stack(const std::initializer_list<T>& init_list) : list_(init_list) {}
1313

1414
~Stack() = default;
1515

16-
void Push(const T& value) { list.push_back(value); }
16+
void Push(const T& value) { list_.push_back(value); }
1717
void Pop() {
1818
if (Empty()) throw std::underflow_error("Stack is empty!");
19-
list.pop_back();
19+
list_.pop_back();
2020
}
2121

2222
T& Top() {
2323
if (Empty()) throw std::underflow_error("Stack is empty!");
24-
return list.back();
24+
return list_.back();
2525
}
26-
bool Empty() { return list.empty(); }
27-
std::size_t Size() { return list.size(); }
26+
bool Empty() { return list_.empty(); }
27+
std::size_t Size() { return list_.size(); }
2828

2929
private:
30-
std::list<T> list;
30+
std::list<T> list_;
3131
};
3232

3333
template <typename T>
3434
class StackMin final {
3535
public:
3636
constexpr StackMin() noexcept {}
37-
StackMin(const StackMin& other) : list(other.list) {}
38-
StackMin(StackMin&& other) : list(other.list) { other.list.clear(); }
39-
StackMin(const std::initializer_list<T>& init_list) : list(init_list) {}
37+
StackMin(const StackMin& other) : list_(other.list_) {}
38+
StackMin(StackMin&& other) : list_(other.list_) { other.list_.clear(); }
39+
StackMin(const std::initializer_list<T>& init_list_) : list_(init_list_) {}
4040

4141
~StackMin() = default;
4242

4343
void Push(const T& value) {
4444
if (min_stack.Empty() || min_stack.Top() > value) min_stack.Push(value);
45-
list.push_back(value);
45+
list_.push_back(value);
4646
}
4747
void Pop() {
4848
if (Empty()) throw std::underflow_error("Stack is empty!");
49-
if (min_stack.Top() == list.back()) min_stack.Pop();
50-
list.pop_back();
49+
if (min_stack.Top() == list_.back()) min_stack.Pop();
50+
list_.pop_back();
5151
}
5252

5353
T& Top() {
5454
if (Empty()) throw std::underflow_error("Stack is empty!");
55-
return list.back();
55+
return list_.back();
5656
}
57-
bool Empty() { return list.empty(); }
58-
std::size_t Size() { return list.size(); }
57+
bool Empty() { return list_.empty(); }
58+
std::size_t Size() { return list_.size(); }
5959

6060
T& Min() { return min_stack.Top(); }
6161

6262
private:
63-
std::list<T> list;
63+
std::list<T> list_;
6464
Stack<T> min_stack;
6565
};

0 commit comments

Comments
 (0)