Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
custom Queue Implementation
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Rextester { public class Program { public static void Main(string[] args) { //custom Queue Implementation - FIFO myQueue que = new myQueue(); que.Enqueue(2); que.Enqueue(4); que.Enqueue(6); que.Enqueue(8); que.printQueue(); que.Dequeue(); que.Dequeue(); que.printQueue(); } } public class myQueue { private int indx; private ArrayList list; public myQueue() { list = new ArrayList(); indx = -1; } public int count { get { return list.Count; } } public void Enqueue(object item) { list.Add(item); indx++; } public object Dequeue() { object obj = list[0]; list.RemoveAt(0); indx--; return obj; } public void clear() { list.Clear(); indx = -1; } public object peek() { return list[indx]; } public void printQueue(){ Console.WriteLine("\n Queue elements"); foreach (int i in list) { Console.WriteLine(i); } Console.WriteLine("Number of elements in the Queue " + count ); Console.WriteLine("Does Queue contain the number 4 "+ list.Contains(4)); } } }
run
|
edit
|
history
|
help
0
adxsadxcasxsd
C# Events and Delegates example
Weird behaiour of conditional operator
sdfrgthyujyhtgrf
Lotto unieke getallen
Converting a string to byte-array without using an encoding (byte-by-byte)
Cotton Farm v: (0.0.0.002)
Main4-4
amstrong number
Check if string is palindrome