formatting source-code for 153fb7b8a5

This commit is contained in:
github-actions
2020-05-30 04:02:09 +00:00
parent 92fe9495ec
commit 8a2de9842b
175 changed files with 1671 additions and 3460 deletions

View File

@@ -5,25 +5,22 @@
using namespace std;
/* Constructor */
cll::cll()
{
cll::cll() {
head = NULL;
total = 0;
}
cll::~cll() { /* Desstructure, no need to fill */ }
cll::~cll() { /* Desstructure, no need to fill */
}
/* Display a list. and total element */
void cll::display()
{
void cll::display() {
if (head == NULL)
cout << "List is empty !" << endl;
else
{
else {
cout << "CLL list: ";
node *current = head;
for (int i = 0; i < total; i++)
{
for (int i = 0; i < total; i++) {
cout << current->data << " -> ";
current = current->next;
}
@@ -33,22 +30,17 @@ void cll::display()
}
/* List insert a new value at head in list */
void cll::insert_front(int new_data)
{
void cll::insert_front(int new_data) {
node *newNode;
newNode = new node;
newNode->data = new_data;
newNode->next = NULL;
if (head == NULL)
{
if (head == NULL) {
head = newNode;
head->next = head;
}
else
{
} else {
node *current = head;
while (current->next != head)
{
while (current->next != head) {
current = current->next;
}
newNode->next = head;
@@ -59,22 +51,17 @@ void cll::insert_front(int new_data)
}
/* List insert a new value at head in list */
void cll::insert_tail(int new_data)
{
void cll::insert_tail(int new_data) {
node *newNode;
newNode = new node;
newNode->data = new_data;
newNode->next = NULL;
if (head == NULL)
{
if (head == NULL) {
head = newNode;
head->next = head;
}
else
{
} else {
node *current = head;
while (current->next != head)
{
while (current->next != head) {
current = current->next;
}
current->next = newNode;
@@ -88,18 +75,13 @@ int cll::get_size() { return total; }
/* Return true if the requested item (sent in as an argument)
is in the list, otherwise return false */
bool cll::find_item(int item_to_find)
{
if (head == NULL)
{
bool cll::find_item(int item_to_find) {
if (head == NULL) {
cout << "List is empty !" << endl;
return false;
}
else
{
} else {
node *current = head;
while (current->next != head)
{
while (current->next != head) {
if (current->data == item_to_find)
return true;
current = current->next;
@@ -113,17 +95,12 @@ int cll::operator*() { return head->data; }
/* Overload the pre-increment operator.
The iterator is advanced to the next node. */
void cll::operator++()
{
if (head == NULL)
{
void cll::operator++() {
if (head == NULL) {
cout << "List is empty !" << endl;
}
else
{
} else {
node *current = head;
while (current->next != head)
{
while (current->next != head) {
current = current->next;
}
current->next = head->next;

View File

@@ -9,14 +9,12 @@
#ifndef CLL_H
#define CLL_H
/*The data structure is a linear linked list of integers */
struct node
{
struct node {
int data;
node* next;
};
class cll
{
class cll {
public:
cll(); /* Construct without parameter */
~cll();

View File

@@ -1,8 +1,7 @@
#include "cll.h"
using namespace std;
int main()
{
int main() {
/* Test CLL */
cout << "----------- Test construct -----------" << endl;
cll list1;