# Algorithms_in_C++: stack_linkedList Class Reference

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

## Public Member Functions

void | enqueue (int)
int | dequeue ()
void | display ()

## Public Attributes

linkedlist * | front
linkedlist * | rear

## Constructor & Destructor Documentation

## stack_linkedList()

stack_linkedList::stack_linkedList | ( |  | ) |

inline

{ front = rear = NULL; }

## Member Function Documentation

## dequeue()

int stack_linkedList::dequeue | ( |  | ) |

{
linkedlist *temp;
int ele;
if (front == NULL)
std::cout << "\nStack is empty";
else {
temp = front;
ele = temp->data;
if (front == rear) // if length of queue is 1;
rear = rear->next;
front = front->next;
delete (temp);
}
return ele;
}
std::cout
linkedlist
Definition: queue_using_linkedlist.cpp:6

## display()

void stack_linkedList::display | ( |  | ) |

{
if (front == NULL)
std::cout << "\nStack is empty";
else {
linkedlist *temp;
temp = front;
while (temp != NULL) {
std::cout << temp->data << " ";
temp = temp->next;
}
}
}

## enqueue()

void stack_linkedList::enqueue | ( | int | ele | ) |

{
linkedlist *temp = new linkedlist();
temp->data = ele;
temp->next = NULL;
if (front == NULL)
front = rear = temp;
else {
rear->next = temp;
rear = temp;
}
}

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

- data_structures/queue_using_linkedlist.cpp