A queue variable declaration needs to meet the following requirements:
- The Queue keyword, its element type between left and right arrow characters, and a unique name
- The new keyword to initialize the queue in memory, followed by the Queue keyword and element type between arrow characters
- A pair of parentheses capped off by a semicolon
In blueprint form, a queue looks as follows:
Queue<elementType> name = new Queue<elementType>();
C# supports a non-generic version of the Queue type that doesn't require you to define the type of element it stores:
Queue myQueue = new Queue();
However, this is less safe and more costly than using the preceding generic version. You can read more about Microsoft's recommendation at https://github.com/dotnet/platform-compat/blob/master/docs/DE0006.md.
Queue myQueue = new Queue();
However, this is less safe and more costly than using the preceding generic version. You can read more about Microsoft's recommendation at https://github.com/dotnet/platform-compat/blob/master/docs/DE0006.md.
An empty queue all by itself isn't all that useful; you want to be able to add, remove, and peek at its elements...