Skip to content

Commit 24e8c40

Browse files
authored
Rename functions
1 parent 9a8d8fa commit 24e8c40

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/cpp/Stack.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Stack {
1414
public:
1515
Stack(){}
1616

17-
bool insert(int element) {
17+
bool push(int element) {
1818
if ((this->elements * TYPE_SIZE) == sizeof(this->arr)) {
1919
return false;
2020
};
@@ -30,7 +30,7 @@ class Stack {
3030
return false;
3131
}
3232

33-
bool remove() {
33+
bool pop() {
3434
if (this->isEmpty()) {
3535
return false;
3636
}
@@ -56,27 +56,27 @@ int main() {
5656
Stack* stack = new Stack();
5757

5858
// Insert Elements, then removes
59-
stack->insert(1);
60-
stack->insert(2);
61-
stack->insert(4);
59+
stack->push(1);
60+
stack->push(2);
61+
stack->push(4);
6262
std:: cout << stack->top() << std::endl;
63-
stack->remove();
63+
stack->pop();
6464
std:: cout << stack->top() << std::endl;
65-
stack->remove();
66-
stack->remove();
65+
stack->pop();
66+
stack->pop();
6767

6868
std::cout << "--------------------" << "\n";
6969

7070
// Try to insert beyond max size
7171
for (int i = 0; i < 15; i++) {
72-
std::cout << stack->insert(i) << std::endl;
72+
std::cout << stack->push(i) << std::endl;
7373
}
7474

7575
std::cout << "--------------------" << "\n";
7676

7777
// Show and remove stack top element
7878
for (int i = 0; i < stack->getSize(); i++) {
7979
std::cout << stack->top() << std::endl;
80-
stack->remove();
80+
stack->pop();
8181
}
8282
}

0 commit comments

Comments
 (0)