formatting source-code for d7af6fdc8c

This commit is contained in:
github-actions
2020-05-29 23:26:30 +00:00
parent edb3d51ec2
commit 7ad1f171c1
176 changed files with 5342 additions and 4288 deletions

View File

@@ -1,6 +1,6 @@
#include <iostream>
#include <assert.h>
#include "stack.h"
#include <assert.h>
#include <iostream>
using namespace std;
@@ -24,11 +24,12 @@ void stack<Type>::display()
{
node<Type> *current = stackTop;
cout << "Top --> ";
while(current != NULL) {
cout<<current->data<< " ";
current = current -> next;
while (current != NULL)
{
cout << current->data << " ";
current = current->next;
}
cout <<endl;
cout << endl;
cout << "Size of stack: " << size << endl;
}
@@ -71,19 +72,22 @@ template <class Type>
void stack<Type>::pop()
{
node<Type> *temp;
if(!isEmptyStack()) {
if (!isEmptyStack())
{
temp = stackTop;
stackTop = stackTop->next;
delete temp;
size--;
} else {
}
else
{
cout << "Stack is empty !" << endl;
}
}
/* Operator "=" */
template <class Type>
stack<Type> stack<Type>::operator=(stack<Type> & otherStack)
stack<Type> stack<Type>::operator=(stack<Type> &otherStack)
{
node<Type> *newNode, *current, *last;
@@ -91,13 +95,14 @@ stack<Type> stack<Type>::operator=(stack<Type> & otherStack)
stackTop = NULL;
if (otherStack.stackTop == NULL)
stackTop = NULL;
else {
else
{
current = otherStack.stackTop;
stackTop = new node<Type>;
stackTop->data = current->data;
stackTop->next = NULL;
last = stackTop;
current = current ->next;
current = current->next;
/* Copy the remaining stack */
while (current != NULL)
{