‫So now we're going to build our constructor for our queue, except our queue is going to look like this.
‫So we have to start out by building a node.
‫And just like we saw with link lists and with our stack, we said that this node is very similar to
‫an unordered map with value and next and that we have a constructor that we pass a value and then we
‫say this value equals value, and then we set that next pointer to null pointer and that is our node
‫class.
‫And this is exactly the same as it was in our linked list.
‫So now we'll start building our queue class and we'll create our member variables.
‫Those will be private, so we'll create pointers to the first and last node like this, and then we'll
‫also keep track of the length.
‫So now let's build the constructor, which will be public, and we'll start that constructor out like
‫this.
‫And now let's focus in on just the constructor.
‫So we're passing the queue of value.
‫We'll use that to create the first node in the queue like this, and then we'll set first and last to
‫be equal to new node like this, and then we'll set the length to be equal to one.
‫So this bring back the rest of our code like this.
‫This is our entire queue class so far.
‫And let's focus back in on just the constructor.
‫We would create a new queue and run this constructor by doing something like this.
‫We'll have a queue called my queue and we'll set it equal to new queue.
‫We'll pass it the number seven, and when we run this line of code it will build all of this.
‫It will create that first node with a value of seven.
‫First and last will point to that node, and that will set the length to be equal to one.
‫So now let's flip over to VS Code and take a look at this.
‫So there is our node class there.
‫I'm going to scroll up a little bit.
‫And this here is the code that we just went through.
‫And then I'm going to scroll up again.
‫And then I also created print queue, get first, get last and get length.
‫And then I'll scroll up again here and we'll look at our main function.
‫So that creates that queue that we just saw with one node with a value of seven and then we'll run,
‫get first, get last, get length and finally we'll run print queue.
‫So I'll run this and you can see that first and last point to a node with a value of seven.
‫The length is one and this is what we get from running print queue and it's showing just that one node
‫with a value of seven.
‫So it looks like we have a working queue constructor.