TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
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

linkedlistfront
 
linkedlistrear
 

Detailed Description

Definition at line 10 of file queue_using_linkedlist.cpp.

Constructor & Destructor Documentation

◆ stack_linkedList()

stack_linkedList::stack_linkedList ( )
inline

Definition at line 15 of file queue_using_linkedlist.cpp.

15{ front = rear = NULL; }

Member Function Documentation

◆ dequeue()

int stack_linkedList::dequeue ( )

Definition at line 32 of file queue_using_linkedlist.cpp.

32 {
33 linkedlist *temp;
34 int ele;
35 if (front == NULL)
36 std::cout << "\nStack is empty";
37 else {
38 temp = front;
39 ele = temp->data;
40 if (front == rear) // if length of queue is 1;
41 rear = rear->next;
42 front = front->next;
43 delete (temp);
44 }
45 return ele;
46}

◆ display()

void stack_linkedList::display ( )

Definition at line 47 of file queue_using_linkedlist.cpp.

47 {
48 if (front == NULL)
49 std::cout << "\nStack is empty";
50
51 else {
52 linkedlist *temp;
53 temp = front;
54 while (temp != NULL) {
55 std::cout << temp->data << " ";
56 temp = temp->next;
57 }
58 }
59}

◆ enqueue()

void stack_linkedList::enqueue ( int ele)

Definition at line 20 of file queue_using_linkedlist.cpp.

20 {
21 linkedlist *temp = new linkedlist();
22 temp->data = ele;
23 temp->next = NULL;
24
25 if (front == NULL)
26 front = rear = temp;
27 else {
28 rear->next = temp;
29 rear = temp;
30 }
31}

Member Data Documentation

◆ front

linkedlist* stack_linkedList::front

Definition at line 12 of file queue_using_linkedlist.cpp.

◆ rear

linkedlist* stack_linkedList::rear

Definition at line 13 of file queue_using_linkedlist.cpp.


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