# Algorithms_in_C++: cll Class Reference

Loading...
Searching...
No Matches
cll Class Reference
Collaboration diagram for cll:
[legend]

## Public Member Functions

void | display ()
void | insert_front (int new_data)
void | insert_tail (int new_data)
int | get_size ()
bool | find_item (int item_to_find)
int | operator* ()
void | operator++ ()

## Protected Attributes

node * | head
int | total

## Constructor & Destructor Documentation

## cll()

cll::cll | ( |  | ) |

{
head = NULL;
total = 0;
}

## ~cll()

cll::~cll | ( |  | ) |

{ /* Desstructure, no need to fill */
}

## Member Function Documentation

## display()

void cll::display | ( |  | ) |

{
if (head == NULL)
cout << "List is empty !" << endl;
else {
cout << "CLL list: ";
node *current = head;
for (int i = 0; i < total; i++) {
cout << current->data << " -> ";
current = current->next;
}
cout << head->data << endl;
cout << "Total element: " << total << endl;
}
}
std::cout
endl
#define endl
Definition: matrix_exponentiation.cpp:36
node
Definition: avltree.cpp:13

## find_item()

bool cll::find_item | ( | int | item_to_find | ) |

{
if (head == NULL) {
cout << "List is empty !" << endl;
return false;
} else {
node *current = head;
while (current->next != head) {
if (current->data == item_to_find)
return true;
current = current->next;
}
return false;
}
}

## get_size()

int cll::get_size | ( |  | ) |

{ return total; }

## insert_front()

void cll::insert_front | ( | int | new_data | ) |

{
node *newNode;
newNode = new node;
newNode->data = new_data;
newNode->next = NULL;
if (head == NULL) {
head = newNode;
head->next = head;
} else {
node *current = head;
while (current->next != head) {
current = current->next;
}
newNode->next = head;
current->next = newNode;
head = newNode;
}
total++;
}

## insert_tail()

void cll::insert_tail | ( | int | new_data | ) |

{
node *newNode;
newNode = new node;
newNode->data = new_data;
newNode->next = NULL;
if (head == NULL) {
head = newNode;
head->next = head;
} else {
node *current = head;
while (current->next != head) {
current = current->next;
}
current->next = newNode;
newNode->next = head;
}
total++;
}

## operator*()

int cll::operator* | ( |  | ) |

{ return head->data; }

## operator++()

void cll::operator++ | ( |  | ) |

{
if (head == NULL) {
cout << "List is empty !" << endl;
} else {
node *current = head;
while (current->next != head) {
current = current->next;
}
current->next = head->next;
head = head->next;
}
total--;
}

The documentation for this class was generated from the following files:

- data_structures/cll/cll.h
- data_structures/cll/cll.cpp