-
Notifications
You must be signed in to change notification settings - Fork 0
/
SLLQueue.cs
57 lines (52 loc) · 1.29 KB
/
SLLQueue.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
namespace DSA
{
public class SLLQueue
{
private SinglyLinkedList queue;
public SLLQueue()
{
queue = new SinglyLinkedList();
}
public void Enqueue(int data)
{
queue.AppendList(data);
}
public void DisplayQueue()
{
if (queue.Head != null)
{
SLLNode? iterator = queue.Head;
for (int i = 0; i < SinglyLinkedList.Count; ++i)
{
Console.Write($"{iterator.Data}-");
iterator = iterator.Next;
}
Console.WriteLine();
}
else
{
Console.WriteLine($"Queue Status : {isEmpty()}");
}
}
public void Dequeue()
{
queue.DeletListNode(1);
}
public string Peek()
{
if (queue.Head != null)
return queue.Head.Data.ToString();
return isEmpty();
}
public string isEmpty()
{
if (SinglyLinkedList.Count == 0)
return "Empty";
return "Not Empty";
}
public string Size()
{
return SinglyLinkedList.Count.ToString();
}
}
}