2020-01-08 07:57:31 +08:00
|
|
|
/*
|
|
|
|
* Simple data structure CLL (Cicular Linear Linked List)
|
|
|
|
* */
|
|
|
|
#include <cctype>
|
|
|
|
#include <cstdlib>
|
2020-05-30 07:26:30 +08:00
|
|
|
#include <cstring>
|
|
|
|
#include <iostream>
|
2020-01-08 07:57:31 +08:00
|
|
|
|
|
|
|
#ifndef CLL_H
|
|
|
|
#define CLL_H
|
|
|
|
/*The data structure is a linear linked list of integers */
|
|
|
|
struct node
|
|
|
|
{
|
2020-05-30 07:26:30 +08:00
|
|
|
int data;
|
|
|
|
node* next;
|
2020-01-08 07:57:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class cll
|
|
|
|
{
|
2020-05-30 07:26:30 +08:00
|
|
|
public:
|
|
|
|
cll(); /* Construct without parameter */
|
|
|
|
~cll();
|
|
|
|
void display(); /* Show the list */
|
2020-01-08 07:57:31 +08:00
|
|
|
|
2020-05-30 07:26:30 +08:00
|
|
|
/******************************************************
|
|
|
|
* Useful method for list
|
|
|
|
*******************************************************/
|
|
|
|
void insert_front(int new_data); /* Insert a new value at head */
|
|
|
|
void insert_tail(int new_data); /* Insert a new value at tail */
|
|
|
|
int get_size(); /* Get total element in list */
|
|
|
|
bool find_item(int item_to_find); /* Find an item in list */
|
2020-01-08 07:57:31 +08:00
|
|
|
|
2020-05-30 07:26:30 +08:00
|
|
|
/******************************************************
|
|
|
|
* Overloading method for list
|
|
|
|
*******************************************************/
|
|
|
|
int operator*(); /* Returns the info contained in head */
|
|
|
|
/* Overload the pre-increment operator.
|
|
|
|
The iterator is advanced to the next node. */
|
|
|
|
void operator++();
|
2020-01-08 07:57:31 +08:00
|
|
|
|
2020-05-30 07:26:30 +08:00
|
|
|
protected:
|
|
|
|
node* head;
|
|
|
|
int total; /* Total element in a list */
|
2020-01-08 07:57:31 +08:00
|
|
|
};
|
|
|
|
#endif
|